View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Gord Dibben Gord Dibben is offline
external usenet poster
 
Posts: 22,906
Default sort by numbers of digits in cells

If you have a "number" with a leading zero, it is either a 5 digit number
custom formatted to 000000 or it is text.

Text and numbers sort differently.

First check to see if the 6 digit leading zero numbers are formatted or if
they are text.

If text, in a helper column enter this formula.

Assumes a title in A1 and data from A2 to wherever.

=IF(LEN(A2)=6,A2,"0"&A2)

Copy down.

Sort on column B.


Gord Dibben MS Excel MVP


On Wed, 20 Aug 2008 13:12:07 -0700, mab2819
wrote:

Hi,

I need to sort a large document by a certain column. That column consists of
numbers that are six digits and five digits. I need to insert a leading zero
in all those numbers that consist of only five digits. Some of those six
digit numbers already correctly have the leading zero, so when I sort, it
doesn't isolate the five digit ones. Any ideas on how I can do this?
TIA,