Sunday, 5 May 2019

worksheet function - Extract Text from String in Excel


Help with a formula to extract text clips out of strings. Turning



  • SP BILL(DL/ON-SITE CONT) into DL/ON CONT

  • ST MISC(TRAVEL) into TRAVEL


I'm having trouble removing "-SITE" from one cell without ruining the other. Here's what I have so far...


=MID(A1,FIND("(",A1)+1,FIND(")",A1,FIND("(",A1)+1)-1-FIND("(",A1))

Answer



Try this, updated to verify the cell in A1 is not blank and contains both ( and ) characters:


=IF(OR(ISERR(FIND("(",A1)),ISERR(FIND(")",A1)),ISBLANK(A1)),"",SUBSTITUTE(MID(A1,FIND("(",A1)+1,FIND(")",A1)-FIND("(",A1)-1),"-SITE",""))

No comments:

Post a Comment

How can I VLOOKUP in multiple Excel documents?

I am trying to VLOOKUP reference data with around 400 seperate Excel files. Is it possible to do this in a quick way rather than doing it m...