View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.misc
Ken Johnson Ken Johnson is offline
external usenet poster
 
Posts: 1,073
Default Macro Help replacing dropped zeros

Hi,
If it has to be a macro this works if you run it after selecting the
range of cells...

Public Sub add_zeros()
Dim vaData As Variant
vaData = Selection
Dim I As Long
Dim J As Long
For I = 1 To UBound(vaData, 1)
For J = 1 To UBound(vaData, 2)
vaData(I, J) = "'" & _
WorksheetFunction.Rept("0", 9 - Len(vaData(I, J))) _
& vaData(I, J)
Next J
Next I
Selection = vaData
End Sub

Ken Johnson