View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Laurin[_5_] Laurin[_5_] is offline
external usenet poster
 
Posts: 1
Default How to preserve leading zeroes


If the numbers all have the same length, you can try the following whic
works on one cell. With a minor bit of modification you can make i
work on all of the returned data using a loop.

Range("A1").Select
Selection.NumberFormat = "@"
Dim I As Variant
I = Range("A1").Value
Select Case Len(I)
Case Is = 1: I = "00000" & I
Case Is = 2: I = "0000" & I
Case Is = 3: I = "000" & I
Case Is = 4: I = "00" & I
Case Is = 5: I = "0" & I
Case Else: I = I
End Select
Range("A1") =

--
Lauri
-----------------------------------------------------------------------
Laurin's Profile: http://www.excelforum.com/member.php...fo&userid=2683
View this thread: http://www.excelforum.com/showthread.php?threadid=49185