formula to analize info in a cell

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a cell that has a mix a text and numbers. I need to know how many of
the charaters are text and how many are numbers. It usually is something
like JDR89765 or JD5674, meaning that the text is on the left side. If
possible I would like to read from left to right and get a count of how many
text char there are before the first number.

Any help will be greatly appreciated.

Thanks in advance.
 
=LEN(A1)-SUMPRODUCT(--ISNUMBER(-RIGHT(A1,ROW(INDIRECT("1:"&LEN(A1)))))

will tell you the number of text characters in the cell
 
One way, assume the string is in A1

=MATCH(TRUE,ISNUMBER(--MID(A1,ROW(INDIRECT("1:"&LEN(A1)))+1,1)),0)

entered with ctrl + shift & enter,

and to get the number of of numbers just use the cell result, assume you put
that formula in B1, in C use

=LEN(A1)-B1

note that if there are spaces they will be counted so you could wrap each
cell refof in the cell with TRIM


=MATCH(TRUE,ISNUMBER(--MID(TRIM(A1),ROW(INDIRECT("1:"&LEN(TRIM(A1))))+1,1)),0)

then

=TRIM(LEN(A1)-B1 for the numbers


Regards,

Peo Sjoblom
 
N said:
=LEN(A1)-SUMPRODUCT(--ISNUMBER(-RIGHT(A1,ROW(INDIRECT("1:"&LEN(A1)))))

will tell you the number of text characters in the cell
....

Not reliably. If A1 contained JDR89765X, your formula returns 9 rather
than 4.

An alternative that works no matter how decimal numerals and other
characters are scrambled is

=SUMPRODUCT(LEN(SUBSTITUTE(G2,{0;1;2;3;4;5;6;7;8;9},"")))-9*LEN(G2)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top