How to extract values after 2 types of character?

Exhell_Simon

New Member
Joined
Aug 3, 2017
Messages
8
Hi folks,

I'm hoping someone might have a formula for this use case. I have a sheet containing a column of data values. the values are like this:

Updated_New_Customer_DE
2016_w32_1_Sunday_ladies [example]

I would like to use a formula to extract the value either after the last underscore_ or the value contained within the [ ] square brackets. The length of what's contained or after the last _can vary. It sort of needs to work right to left I guess.

So the above would generate values of:

DE
example

Thanks


Simon

I have searched and can't find this previously asked.

Many Thanks


Simon
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Welcome to the board.

One option:

=TRIM(RIGHT(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1,"[","_"),"]",""),"_",REPT(" ",LEN(A1))),LEN(A1)))
 
Upvote 0
Eric, a big thank you for such a speedy reply that did indeed work. My efforts so far involved some lashed up formula involving LEN and FIND but didn't work. Much appreciated.
 
Upvote 0
Well i spent time on this so I may as well post it but I'd go with Erics solution as it's shorter

=IF(ISNUMBER(SEARCH("[",A1)),MID(A1,FIND("[",A1)+1,FIND("]",A1)-FIND("[",A1)-1),TRIM(RIGHT(SUBSTITUTE(A1,"_",REPT(" ",LEN(A1))),LEN(A1))))
 
Upvote 0

Forum statistics

Threads
1,215,637
Messages
6,125,965
Members
449,276
Latest member
surendra75

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top