If Cell Starts with Text String... Formula

ggmkp picture ggmkp · Jul 25, 2013 · Viewed 176.9k times · Source

I have formula that checks if the cell starts with text "A" returns Pick up "B" for Collect and C for Prepaid.

But it doesn't seems to be working properly

Both A and C returns Prepaid...

=LOOKUP(LEFT(A1),{"A","B","C"},{"Pick Up","Collect","Prepaid"})

Answer

Raystafarian picture Raystafarian · Jul 25, 2013

I'm not sure lookup is the right formula for this because of multiple arguments. Maybe hlookup or vlookup but these require you to have tables for values. A simple nested series of if does the trick for a small sample size

Try =IF(A1="a","pickup",IF(A1="b","collect",IF(A1="c","prepaid","")))

Now incorporate your left argument

=IF(LEFT(A1,1)="a","pickup",IF(LEFT(A1,1)="b","collect",IF(LEFT(A1,1)="c","prepaid","")))

Also note your usage of left, your argument doesn't specify the number of characters, but a set.


7/8/15 - Microsoft KB articles for the above mentioned functions. I don't think there's anything wrong with techonthenet, but I rather link to official sources.