Reputation: 1
I'm trying to use theIF
statement with theSEARCH
andLEFT
functions in Excel to search for a string and then display the string.
The first portion of theIF
statement 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 nestedIF
statement 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
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