5

I am trying to find a good way to use Excel to determine whether a cell's first character is a number or a letter. I am using this to determine a flag that gets marked or not depending on the answer. Here is an example table:

**Status    Code**
Inactive    2AJ
Active      ALO
Active      PN9
Active      Y2Y
Inactive    1P9

Essentially, if the beginning character of the Code column is a numeric value, the Status column should show "Inactive". Currently I have this and it doesn't work:

=IF(ISNUMBER(LEFT(B1,1)),"Inactive","Active")
1
  • 2
    Try =IF(ISNUMBER(--LEFT(B1)),"Inactive","Active").LEFT function defaults to a single character.
    – user4039065
    Oct 28, 2014 at 18:33

2 Answers 2

15

Formula:

=IF(ISNUMBER(VALUE(LEFT(B2,1))),"Inactive","Active")

You were trying to see if a number stored as a string was a number. This fixes that issue.

1
  • @JoshuaBurton, if it worked, please mark it with the green check mark as the answer. Oct 28, 2014 at 18:42
1

Please try:

=IF(AND(CODE(LEFT(B2,1))>47,CODE(LEFT(B2,1))<58),"Inactive","Active")  

copied down to suit.

This might then be compared against the ColumnA values to flag any discrepancies.

2
  • 1
    Somebody has downmarked the solution using the CODE function, maybe thinking it's implementation dependent e.g. won't work on a Mac. I think it will because the first 128 ASCII characters are supposed to be the same on a Mac. Only other comment at risk of being nit-picking, CODE looks at the first character of a string so =IF(AND(CODE(B2)>47,CODE(B2)<58),"Inactive","Active") would suffice.
    – Tom Sharpe
    Oct 28, 2014 at 19:40
  • 1
    Good point, have to think about a solution being adaptable as well as answering the current question.
    – Tom Sharpe
    Oct 28, 2014 at 20:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.