Filling cells with sequential numbers in an Excel (2003) macro
- by Fred Hamilton
I need to fill an excel column with a sequential series, in this case from -500 to 1000. I've got a macro to do it, but it takes a lot of lines for something that seems like it should be a single function [something like FillRange(A2:A1502, -500, 1000, 1)]. But if that function exists, I can't find it. Is the following as simple and elegant as it gets?
'Draw X axis scale
Cells(1, 1).Value = "mV"
Cells(2, 1).Value = -500
Cells(3, 1).Value = -499
Cells(4, 1).Value = -498
Dim selection1 As Range, selection2 As Range
Set selection1 = Sheet1.Range("A2:A4")
Set selection2 = Sheet1.Range("A2:A1502")
selection1.AutoFill Destination:=selection2