ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Auto Increment Number (https://www.excelbanter.com/excel-discussion-misc-queries/192462-re-auto-increment-number.html)

Thomas [PBD]

Auto Increment Number
 
E_Dirksen,

I have created a macro for you. Please place this into a module inside of
VBA and run the Macro (ToolsMacroNumber_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

"E_Dirksen" wrote:

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?



All times are GMT +1. The time now is 01:48 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com