# Sequential Numbers

#### mrpoo

##### New Member
I have a userform with a starting serial number (textbox1) and another textbox with a quantity (textbox 2)
How can I insert a sequential range of numbers into column A, starting with that initial number in textbox 1 to the row quantity that is in textbox 2?

Many thanks,
Graham

### Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.

#### rpaulson

##### Well-known Member
VBA Code:
``````Private Sub CommandButton1_Click()

[A1] = TextBox1.Value
For r = 2 To TextBox2.Value
Cells(r, "A") = Cells(r - 1, "A") + 1
Next r

End Sub``````

#### mrpoo

##### New Member
Hi,

It works, ish. If I put 1 as the starting number for a quantity of 5, it only displays 1 - 4? Also, I'm struggling to make the sequence start on row 5 within the sheet instead of the top of row a?

Many thanks,
Graham

#### rpaulson

##### Well-known Member
i'm confused on exactly what you are looking to do?

if the user enters a 7 for Textbox1 and a 19 for Textbox2.
what cells are you wanting populated with what values?

#### mrpoo

##### New Member
Apologies for late replay, I have a form where I need a starting serial number entered into textbox1, and the quantity required in textbox2:

Textbox1 - Starting serial = 1
Textbox2 - Quantity = 5

And the results starting from cell H5
1
2
3
4
5

Thanks,
Graham

#### rpaulson

##### Well-known Member
VBA Code:
``````Private Sub CommandButton1_Click()

For r = TextBox1.Value To TextBox2.Value
Cells(r-1+TextBox2.Value, "H") = r
Next r

End Sub``````

Replies
10
Views
179
Replies
1
Views
158
Replies
3
Views
142
Replies
4
Views
148
Replies
0
Views
46

1,130,246
Messages
5,641,083
Members
417,193
Latest member
J00490

### We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.

### Which adblocker are you using?

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

### Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

### Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back