If Statement for text / numbers

brumby

Active Member
Joined
Apr 1, 2003
Messages
400
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....

=IF(A5="CELL CONTENTS START WITH A NUMBER","A","B")

Is this possible?


Many Thanks
 

Excel Facts

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

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
67,156
Office Version
  1. 365
Platform
  1. Windows
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")
 
Upvote 0

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
67,156
Office Version
  1. 365
Platform
  1. Windows
=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:
Upvote 0

brumby

Active Member
Joined
Apr 1, 2003
Messages
400
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?
 
Upvote 0

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
67,156
Office Version
  1. 365
Platform
  1. Windows
Do you mean that if TRUE, you want to simply return that one character?
LEFT(A5,1)
would do that.
 
Upvote 0

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
67,156
Office Version
  1. 365
Platform
  1. Windows
You can either use:
""""
or
CHAR(34)
 
Last edited:
Upvote 0

Forum statistics

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

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
Top