# Microsoft Office Application Help - Excel Help forum > Excel General >  >  IF Function - Begins With

## Cecil

How do I apply the "begins with" filter to an IF statement?  I would like to test a match on the first 3 characters of a string in a given cell?

----------


## SteveG

Cecil,

=IF(LEFT(A1,3)="ABCD",A1,"")

This will look at the 3 leftmost characters and return a value if it is true.

Regards,

Steve

----------


## SteveG

Cecil,


=IF(LEFT(A1,3)="ABC",A1,"")

Only indicate 3 characters in quotes.  My last example had 4.  Sorry!

Cheers,

Steve

----------


## Cecil

Yes, that's it!  Thanks, Steve.

----------


## Jencentric

Would this formula work on numbers, or do I need to change the numbers to text first?

----------


## shg

Welcome to the board.

What happened when you tried?

----------


## Jencentric

Thanks! Long time lurker/learner from these forums, first time responding!

I got an answer, but it wasn't the right one. It didn't error out. 
I think I'm going to try to do something along the line of the below since it is a number (once my brain can wrap around where this AND function goes along with the AND and ORs I already have going on...)

=IF(AND(C1>=A1,C1<=B1),"between","not between")

(from: http://www.mrexcel.com/forum/excel-q...wo-values.html)

----------


## shg

Good job sorting it out.

----------


## mintyfresh2020

so I need to do something like if a3 starts with a then j3 has this output, or if a3 starts with x then j3has this output, I'm getting lost in the nesting

----------


## FDibbins

> so I need to do something like if a3 starts with a then j3 has this output, or if a3 starts with x then j3has this output, I'm getting lost in the nesting



*Administrative Note:*

Welcome to the forum.  :Smilie: 

We are happy to help, however whilst you feel your request is similar to this thread, experience has shown that things soon get confusing when answers refer to particular cells/ranges/sheets which are unique to your post and not relevant to the original.

Please see Forum Rule #4 about hijacking and start a new thread for your query.

If you are not familiar with how to start a new thread see the FAQ: How to start a new thread

----------


## Toolman954

I am in need of an IF Function that will check the first three characters in Column B and Set a Text Value in Column A for that row

Example:  If Cell B1 = P42ABC123N, Then cell A1 is set to "F32"

IF B1 Begins with P21, Set A1 to F21 or,
If B1 Begins with P24, Set A1 to F24 or,
If B1 Begins with P28, Set A1 to F28 or,
If B1 Begins with P12, Set A1 to F32 or,
If B1 Begins with P32, Set A1 to F32 or,
If B1 Begins with P42, Set A1 to F32 or,
If B1 Begins with P33, Set A1 to S33 or,
If B1 Begins with P46, Set A1 to S46

----------


## AliGW

*Administrative Note:*

Welcome to the forum.  :Smilie: 

We are happy to help, however whilst you feel your request is similar to this thread, experience has shown that things soon get confusing when answers refer to particular cells/ranges/sheets which are unique to your post and not relevant to the original.

Please see Forum Rule #4 about hijacking and start a new thread for your query.

If you are not familiar with how to start a new thread see the FAQ: How to start a new thread

----------

