Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel 2010 - Extract specific text from cell 2

Status
Not open for further replies.

cpjeffm

IS-IT--Management
Mar 9, 2015
73
US
I have a text field in cell H2 that contains either "LH" or "RH" (see examples below). I need to extract the "LH" or "RH" into cell I2.

If H2 shows "CARAVN 07 RH (((NEW IN STOCK))) (CH23R)", I need cell I2 to show RH
If H2 shows "SUB150 02 Int.2972 LH (((NEW IN STOCK))) (CV23EL)", I need cell I2 to show LH

Thanks in advance!

 


Sorry, use this instead...

[tt]
=IFERROR(IF(FIND("RH",H2)>0,"RH"),"LH")
[/tt]
 
Ok that worked great but I failed to mention that LH or RH will not always be present in the text so can you build in a check for that and return "" if LH or RH isn't present?
 
Assuming mutually exclusive findings, with possibility to extend the function:
[tt]=CHOOSE(1+IF(ISERROR(SEARCH("LH",A1)),0,1)+IF(ISERROR(SEARCH("RH",A1)),0,2),"","LH","RH")[/tt]

combo
 
Combo, your formula returned no results.
 
I got it. I had to change the A1 in the formula to H1 and that fixed it. Thanks to you both!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top