# If Statement for text / numbers

#### brumby

##### Active Member
Hiya all,

Is it possible to have an if type statement to look at the first character of a cell to see if it starts with a number or a text letter?

something like....

Is this possible?

Many Thanks

### Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce

#### Joe4

##### MrExcel MVP, Junior Admin
Here is one way:
Code:
``=IF(AND(CODE(LEFT(A5,1))>=48,CODE(LEFT(A5,1))<=57),"It is a number","It is not a number")``

#### T. Valko

##### Well-known Member
something like....

One way...

=IF(COUNT(-LEFT(A5)),"A","B")

#### Joe4

##### MrExcel MVP, Junior Admin
=IF(COUNT(-LEFT(A5)),"A","B")
Clever!
Taking advantage of the fact that COUNT only counts numbers and using a negative to coerce the string of a number to be read as a number...

Last edited:

#### brumby

##### Active Member
thanks guys, superb!!!!

#### brumby

##### Active Member
sorry 1 more request,

If true I want to return a ", yes simple return the character ", I thought i would do that by entering """, but it doesnt work?

#### Joe4

##### MrExcel MVP, Junior Admin
Do you mean that if TRUE, you want to simply return that one character?
LEFT(A5,1)
would do that.

#### brumby

##### Active Member
not quite, if true I want to return the " symbol

#### Joe4

##### MrExcel MVP, Junior Admin
You can either use:
""""
or
CHAR(34)

Last edited:

#### T. Valko

##### Well-known Member
not quite, if true I want to return the " symbol

So what do you want if FALSE?

This will return " if TRUE and a blank "" if FALSE:

=IF(COUNT(-LEFT(A5)),"""","")

Replies
4
Views
337
Replies
2
Views
273
Replies
6
Views
202
Replies
10
Views
1K
Replies
9
Views
463

1,191,684
Messages
5,987,998
Members
440,125
Latest member
vincentchu2369

### 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?

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