• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Formula to test first two characters of a text string? [SOLVED]

Jn

New Member
I know this should be relatively simple, I just can't figure out all the pipefitting.


I have a column of text strings (codes) that start with certain strings (for example, "PV", "SS", "WL") and I want a formula that returns / sets a value based on those strings.


I was hoping to use a simple "IF" formula, perhaps like this (although this doesn't work):


=IF(A4="PV*","P-1",IF(A4="SS*","P-2","P-3"))


of course the "PV*" doesn't work ... so I guess I just need to know how to match the first 2 characters of the string in the cell I'm checking?
 
Jn


Firstly, Welcome to the Chandoo.org Forums


=IF(left(A4,2)="PV","P-1",IF(left(A4,2)="SS","P-2","P-3"))
 
Thank you Hui, perfect. I knew it was simple, but my brain isn't up to speed yet today.
 
Back
Top