#1
|
|||
|
|||
set variable for string after first underscore
HI,
I'm having a senior moment. I'm wanting to get text after the first underscore. My data look s like this: z_WWWWW_PR zzz_AAAA_pk What I'm looking for is: WWWWW_PR AAA_pk I've search for a answer and found something close to what I want but it remove both underscores. Any help appreciated. Thanks |
#2
|
|||
|
|||
The worksheet formula is like (assumed the text is in cell A2, on fly)
Code:
=IFERROR(RIGHT(A2,Find("_",A2)), A2) Code:
=IF(ISERROR(RIGHT(A2,Find("_",A2)-1)), A2,RIGHT(A2,Find("_",A2))) Something like: Code:
If InStr(SourceVariable, "_") = 0 Then ResultVariable = SourceVariable Else ResultVariable = Right(SourceVariable, Len(SourceVariable) - InStr(SourceVariable, "_")) End If |
#3
|
|||
|
|||
Arv,
Thanks for the reply. I should have mention I wanted to use code. And have a variable for the result. Thanks Last edited by charlesdh; 07-09-2018 at 11:38 AM. Reason: added info |
#4
|
|||
|
|||
I updated my 1st post!
|
#5
|
|||
|
|||
Arv,
Thanks for the help. Your code works. |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Assigning a string variable to a userform label caption | Larry_1 | Excel Programming | 3 | 12-18-2017 06:59 AM |
I want to create a bar chart of multiple variable. Then I need to draw trend lin of those variable | shimulsiddiquee | Excel | 1 | 05-16-2017 07:39 AM |
Emails to recipients with underscore in email address not received | gjskerritt | Outlook | 0 | 03-14-2017 06:27 PM |
Run Time Error '91': Object variable or With block variable not set using Catalogue Mailmerge | Berryblue | Mail Merge | 1 | 11-13-2014 05:36 PM |
Why unable to use underscore in microsoft word styles( user defined)? | noufalcm | Word | 1 | 03-08-2011 01:46 PM |