Formula IF starts with, not contains

slinky192001

Board Regular
Joined
Mar 16, 2007
Messages
100
Hello

I have a the below formula which checks is a cell contains a certain phrase. I want to amend this to only work if the cell starts with the phrase. Can anyone help?

=IF(ISNUMBER(SEARCH("*A3P - SV*",Q2)),"SV",IF(ISNUMBER(SEARCH("*A3P - SP*",Q2)),"SP",IF(ISNUMBER(SEARCH("*A3P - DCS*",Q2)),"DCS",IF(AND(ISNUMBER(SEARCH("*HHU*",Q2)),AI2=0),"HHU",I2))))

Thank You
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
=IF(ISNUMBER(SEARCH("*A3P - SV*",Q2)),"SV",IF(ISNUMBER(SEARCH("*A3P - SP*",Q2)),"SP",IF(ISNUMBER(SEARCH("*A3P - DCS*",Q2)),"DCS",IF(AND(ISNUMBER(SEARCH("*HHU*",Q2)),AI2=0),"HHU",I2))))

Replace the leading star's as in
=IF(ISNUMBER(SEARCH("*A3P - SV*",Q2)),"

with

=IF(ISNUMBER(SEARCH("A3P - SV*",Q2)),"
 
Upvote 0
=IF(ISNUMBER(SEARCH("*A3P - SV*",Q2)),"SV",IF(ISNUMBER(SEARCH("*A3P - SP*",Q2)),"SP",IF(ISNUMBER(SEARCH("*A3P - DCS*",Q2)),"DCS",IF(AND(ISNUMBER(SEARCH("*HHU*",Q2)),AI2=0),"HHU",I2))))

Replace the leading star's as in
=IF(ISNUMBER(SEARCH("*A3P - SV*",Q2)),"

with

=IF(ISNUMBER(SEARCH("A3P - SV*",Q2)),"

or more specifically

OR =IF(LEFT(Q2,len("A3P - SV"))="A3P - SV","SV....
which checks the text of a cell from the left or start


=IF(LEFT(Q2,LEN("A3P - SV"))="A3P - SV","SV",IF(LEFT(Q2,LEN("*A3P - SP*"))="A3P - SP","SP",IF(LEFT(Q2,LEN("A3P - DCS"))="A3P – DCS”,"DCS",IF(AND(LEFT(Q2,LEN("HHU"))=”HHU”,AI2=0),"HHU",I2))))
 
Last edited:
Upvote 0
Hi,

Thank you, i tried this but it doesnt work, it still picks it up if A3P - SV is in the middle of the string of text.

However, requirements have just changed and I no longer need this.

But thank you very much, always helpful on this forum.

C
 
Upvote 0
Not sure what you are trying to do but SEARCH returns the place in teh string where it occurs so

=IF(ISNUMBER(SEARCH("A3P - SV*",Q2)),

Will evaluate True wherever A3P-SV appears in Q2

So you probably need something that looks like this

=IF((ISNUMBER(SEARCH("A3P - SV*",Q2)),if(SEARCH("A3P - SV*",Q2)=1,....

and so on!
 
Upvote 0

Forum statistics

Threads
1,224,527
Messages
6,179,351
Members
452,907
Latest member
Roland Deschain

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