rsha
rsha

Reputation: 1

Trying to use multiple IF statement with search function in Excel

I'm trying to use theIFstatement with theSEARCHandLEFTfunctions in Excel to search for a string and then display the string.

The first portion of theIFstatement is working but it's not working for second. Please let me know what is wrong with my code. The statements work fine separately but when I use the code as nestedIFstatement it doesn't work.

=IF(SEARCH("COST", A4, 1), LEFT(A4, (SEARCH("COST", A4, 1) -1)), IF(SEARCH("VSE", A4, 1), LEFT(A4, (SEARCH( "VSE", A4, 1) -1))))

Upvotes: 0

Views: 138

Answers (1)

L42
L42

Reputation: 19727

If you are using 2007 and up you can try this:

=IFERROR(IFERROR(LEFT(A4,SEARCH("COST",A4)-1),LEFT(A4,SEARCH("VSE",A4)-1)),"")

Problem is, if COST is not found, it errors out so it will not proceed with finding VSE. HTH.

Upvotes: 1

Related Questions