Sequential Numbers

mrpoo

New Member
Joined
Apr 12, 2018
Messages
17
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

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
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
 
Upvote 0
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
 
Upvote 0
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?
 
Upvote 0
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
 
Upvote 0
VBA Code:
Private Sub CommandButton1_Click()

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

End Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,214,523
Messages
6,120,039
Members
448,940
Latest member
mdusw

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.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

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

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

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
Back
Top