View Full Version : counting digits in a cell


DrJimmy
06-09-2009, 05:10 AM
Hi,

Does anyone know of a quick way of counting the number of digits within a given cell ref?

Cheers

namliam
06-09-2009, 05:13 AM
len(row(reference))

Is that what you are looking for?

DrJimmy
06-09-2009, 05:30 AM
Doesn't seem to give me the number I'd expect. When I apply it to a cell ref where the contents are 24.12 it says 16 is the answer. I'd expect eithe 4 or 5?

Cheers

Mr. B
06-09-2009, 05:50 AM
Just use:

Len(Reference)

this will return the length, including the decimal.

To test, if your entry of 24.12 is in "B3" just enter in some other cell as:
= Len(B3)
you will get 5

You can use this Len() function in VBA also.

DrJimmy
06-09-2009, 06:00 AM
That's done the trick. I tried it before and for some reason it didn't bring back the expected result. Oh well....!

Cheers

namliam
06-09-2009, 06:25 AM
I was thinking just the Len() would to too easy ... LOL

Glad you found it!

Mr. B
06-09-2009, 06:34 AM
Yeah, the "row" that you included would cause a problem with the Len() function.

Glad to help.

namliam
06-09-2009, 06:37 AM
I interperted it is he as looking for the number of didgets on a full cell reference...
i.e.
A1 = 1 didget
AA1 = 1 didget
AA 10000 = 5 didgets.