Using multiple FIND with TRIM & SUBSTITUTE

Executioner

Board Regular
Joined
Sep 26, 2005
Messages
166
Hi everyone, I'm using Excel version 2016.

I have a spreadsheet with 7,517 rows of data in column B. I currently have this formula for finding "EMP" in the text:
=TRIM(IF(ISNUMBER(FIND("-",MID(B2,FIND("EMP",B2),10))),SUBSTITUTE(MID(B2,FIND("EMP",B2),10),"-",""),MID(B2,FIND("EMP",B2),10)))

I need to also include "ES" and "TS" text. I tried reformatting the formula, but with no luck. Each text in B contains either:
EMP#######
ES#####
TS#####

The "#" represents numbers after the letters. So a correct formula would return "EMP2010018" for example. My current formula works fine, but I also need it to locate the ES and TS information. Any suggestions are greatly appreciated.
 
OK, the problem was is that your data is not consistent, some of the spaces are actual spaces, some are non-breaking spaces and some don't have some spaces in that part of the data at all.

Try this:
=IFERROR(TRIM(LEFT(SUBSTITUTE(MID(SUBSTITUTE(SUBSTITUTE(B2,CHAR(160),"")," ",""),LOOKUP(9.99999999E+307,FIND({"-EMP","-ES","-TS"},SUBSTITUTE(SUBSTITUTE(B2,CHAR(160),"")," ","")))+1,255),"-",REPT(" ",255)),255)),"not found")

Copy down.
 
Upvote 0

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Hi Scott. Thanks for taking the time to review this. I still have no idea how your formula works. I'm familiar with some of the commands, but I've never have used:
IFERROR
CHAR
LOOKUP
REPT
As for the data, I used a program called "Cognos" that pulls data from a database program called "Maximo". I thought maybe by changing the data to text, it would fix the issue, but no cigar.
 
Upvote 0
I tried my formula on your spreadsheet and it worked fine, how is it not working exactly?
 
Upvote 0

Forum statistics

Threads
1,224,827
Messages
6,181,200
Members
453,022
Latest member
RobertV1609

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