View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.misc
Rick Rothstein \(MVP - VB\)[_289_] Rick Rothstein \(MVP - VB\)[_289_] is offline
external usenet poster
 
Posts: 1
Default padding numbers in excel

Assuming 1 through 9 have the single leading zero as show for 01 and 02 (and
assuming your first value is in A1)...

=IF(LEN(A1)=6,REPLACE(A1,2,0,"0"),A1)

and copy down.

Rick


"Joe" wrote in message ...
I have a similar problem I'm hoping someone can help me with. I have a
fairly large spreed sheet in excel 25000 rows by 350 columns (so lots of
numbers). In each cell, there is a value that is made up of letters and
numbers such as:

h01a01
y02d07
y120g06
y89a05

The first letter has a single meaning (th project).

The number(s) that follows this first letter, 01, 02, 89, 120 also refer
to a single unit -that is there is a number 1, 2, 89, 120 and so on. The
problem is that using the sort function in excel returns the number 89
after 120 as shown above because excel reads the first number "1" of 120
and the "8" of 89 and says "hey 1 come before 8". Of course I realize the
solution is to put a "0" in fromnt of 89 so that the number is
089 -problem solved by I have no idea how to write a formula in excel to
take care of the problem. PLEASE HELP! Thanks, Joe