Auto Increment Number

E

E_Dirksen

Hello,

I've been trying to create a Macro that when a button is clicked, the cell
will place a number in the box and then move down one row in the same column.
I can ove the cell down a row but I need to be able to automatically
incrment the number by 1 each time. Can anyone help?
 
T

Thomas [PBD]

E_Dirksen,

I have created a macro for you. Please place this into a module inside of
VBA and run the Macro (Tools>Macro>Number_Range).
It can be amended to start at the active cell, but currently it will ask you
what Range and then what you want the starting number to be.

Sub Number_Range()
Dim xlssheet As Excel.Worksheet
Dim x As Long
Dim rng As String
Dim y As Long
Dim z As Long

Set xlssheet = Excel.ActiveSheet
x = 1
rng = InputBox("Enter Range (i.e. A1:A5)", "Range")
y = InputBox("Enter Starting Value", "Start")


xlssheet.Range(rng).Select
z = Selection.Cells.Count

For x = 1 To z
xlssheet.Cells(x, 1).Value = y
y = y + 1
Next

End Sub
 
Top