Joe4
MrExcel MVP, Junior Admin
- Joined
- Aug 1, 2002
- Messages
- 74,735
- Office Version
- 365
- Platform
- Windows
I am trying to autofill two columns of data with numeric values that I do NOT want to increment. I have tried formatting the columns as Text and entering them in as text as well, but it makes no difference.
Here is the code:
The desired output is:
0001 1
0001 1
0001 1
etc.
I am getting:
0001 1
0002 2
0003 3
etc.
How do I keep autofill from incrementing in my VBA code?
Thanks.
Here is the code:
Code:
Sub MyFormat()
' Capture last row
Dim myLastRow As Long
myLastRow = Range("A65536").End(xlUp).Row
' Autofill columns E & F
Columns("E:F").NumberFormat = "@"
Range("E1").FormulaR1C1 = "'0001"
Range("E1").AutoFill Destination:=Range("E1:E" & myLastRow)
Range("F1").FormulaR1C1 = "'1"
Range("F1").AutoFill Destination:=Range("F1:F" & myLastRow)
End Sub
The desired output is:
0001 1
0001 1
0001 1
etc.
I am getting:
0001 1
0002 2
0003 3
etc.
How do I keep autofill from incrementing in my VBA code?
Thanks.