formula to find the position of the "previous" instance of a character within a search string

ellison

Active Member
Joined
Aug 1, 2012
Messages
356
Office Version
  1. 365
Platform
  1. Windows
Hi, we are trying to clean some data up & extract text which ends: 883;" from search strings...

EG we would like to extract 2N5883 out of cell B2 = ;XYZ12;2N5883;B73304001;B73304;;;;;;;;

The plan is to use the MID function with a helper column:

a) SEARCH("883;",B2)+3 to find the position of the character in the 883;
in the above instance, it would return "14" as that ";" is the 14th character

b) MID function:

text will be the search string = B2
start_num will be: the position of the ";" which is to the "to the left" the 14th character (*********no idea how to do this*******)
num_chars will be: 14 minus whatever number is returned by the start_num

c) end result to hopefully be:

MID(B2,14,14-7)
=2N5883

So if somebody could help us to find the "position of the character to the left of its next occurrence" that would be really appreicated!

Best
Neil
PS need to find a formula as opposed to macro please
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Howabout
=TRIM(RIGHT(SUBSTITUTE(LEFT(B2,SEARCH("883;",B2)+2),";",REPT(" ",200)),200))
 
Upvote 0
wow, that is BRILLIANT!!!! CASE CLOSED!!!!!

joking aside, many thanks indeed.

warm regards

Neil
 
Upvote 0
Glad to help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,240
Members
452,621
Latest member
Laura_PinksBTHFT

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