View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
[email protected] J.Evans.1970@gmail.com is offline
external usenet poster
 
Posts: 5
Default Format for Leading Zeros

There's probably a better way, but this would work....


Dim X As Integer
Dim wb As Workbook
Application.ScreenUpdating = False
Set wb = Workbooks.Open("C:\FOReport.xls", True, True)
With ThisWorkbook.Worksheets("Report")
.Range("A5:F798") = ""
.Range("A5:F798").Value =
wb.Worksheets("Report").Range("C7:H80").Value
.Range("A5:F798").NumberFormat = "@"
For X = 5 To 798
.Range("A" & X & ":A" & X).Value = Format(.Range("A" & X & ":A"
& X).Value, "00000")
.Range("B" & X & ":B" & X).Value = Format(.Range("B" & X & ":B"
& X).Value, "00000")
.Range("C" & X & ":C" & X).Value = Format(.Range("C" & X & ":C"
& X).Value, "00000")
.Range("D" & X & ":D" & X).Value = Format(.Range("D" & X & ":D"
& X).Value, "00000")
.Range("E" & X & ":E" & X).Value = Format(.Range("E" & X & ":E"
& X).Value, "00000")
.Range("F" & X & ":F" & X).Value = Format(.Range("F" & X & ":F"
& X).Value, "00000")
Next
End With