return value based on number of characters in cell / field

  • Thread starter Thread starter Perplexed
  • Start date Start date
P

Perplexed

I have a field with varying number of characters, I need function that
returns a value based on the number of characters in field.

ie if field x <2 characters = 1 >2 characters = 2

Thanks
 
How about exactly 2 chars?

=MAX(IF(LEN(A1)>=2,2),1) returns 1 if <2 otherwise returns 2


Gord Dibben MS Excel MVP
 
Here is one more formula for you to consider...

=1+(LEN(A1)>=2)

You didn't define what should happen if there are exact two characters in
the cell, so I treated it the same as when there are more than two
characters in the cell. If that is wrong, just change the >= to > by itself.
 
Hi

=MIN(LEN(A4),2)

However, since you didn't tell us what to do if len=2, I choose to treat it
as >=2
 
Back
Top