B
B Roberson
I have the macro listed below that does generate a numeric value for each cell in column D for as many rows as there are records. I would like to adjust this macro to where if the counter is less than 10, that the active cellwould get 001,002 etc. If it is 35, it should past 035 as text, and if its625, it would not have to paste any leading zeroes in that case. So, I guess I need a case or a series of if then else type structure, but I am not sure how to format the "0", "00", or no leading zeroes depending on the number involved.
Sub add_page_and_line_new()
Dim cRows As Long
cRows = Cells(Rows.Count, "A").End(xlUp).Row
Dim linenumcounter As Integer
linenumcounter = 1
Range("d1").Select
For i = 1 To cRows
If linecounter < 10 Then
With ActiveCell
.Value = linenumcounter
.Copy
.PasteSpecial Paste:=xlValues
.Offset(1, 0).Select
End With
linenumcounter = linenumcounter + 1
End With
Next
Sub add_page_and_line_new()
Dim cRows As Long
cRows = Cells(Rows.Count, "A").End(xlUp).Row
Dim linenumcounter As Integer
linenumcounter = 1
Range("d1").Select
For i = 1 To cRows
If linecounter < 10 Then
With ActiveCell
.Value = linenumcounter
.Copy
.PasteSpecial Paste:=xlValues
.Offset(1, 0).Select
End With
linenumcounter = linenumcounter + 1
End With
Next