ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   return value based on number of characters in cell / field (https://www.excelbanter.com/excel-worksheet-functions/213184-return-value-based-number-characters-cell-field.html)

Perplexed

return value based on number of characters in cell / field
 
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

David Biddulph[_2_]

return value based on number of characters in cell / field
 
Use the LEN function. Look it up in Excel help.
--
David Biddulph

"Perplexed" wrote in message
...
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




Gord Dibben

return value based on number of characters in cell / field
 
How about exactly 2 chars?

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


Gord Dibben MS Excel MVP

On Wed, 10 Dec 2008 11:47:00 -0800, Perplexed
wrote:

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



Rick Rothstein

return value based on number of characters in cell / field
 
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.

--
Rick (MVP - Excel)


"Perplexed" wrote in message
...
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



Shane Devenshire[_2_]

return value based on number of characters in cell / field
 
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

--
If this helps, please click the Yes button

Cheers,
Shane Devenshire


"Perplexed" wrote:

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



All times are GMT +1. The time now is 05:48 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com