Macro Requested for intermittent repeating alpha-numeric sequence generation

Technical Joe

New Member
Joined
Mar 20, 2017
Messages
1
I would like to have one or more macros to be shared with anyone working on the similar worksheets. I would like it to create a sequence to read like the following example:

ABC-0001
ABC-0001
ABC-0001
ABC-0002
ABC-0002
ABC-0002
ABC-0003
ABC-0003
ABC-0003

and, start from a higher number:

ABC-0050
ABC-0050
ABC-0050
ABC-0050
ABC-0051
ABC-0051
ABC-0051
ABC-0051
ABC-0052
ABC-0052
ABC-0052
ABC-0052

The ability to increment with additional letters or numbers involved would be helpful, but understandably difficult:

A-ABC-0052-X
A-ABC-0052-Q
A-ABC-0052-S
B-ABC-0052
D-ABC-0052
A-ABC-0053-X
A-ABC-0053-Q
A-ABC-0053-S
B-ABC-0053
D-ABC-0053
A-ABC-0054-X
A-ABC-0054-Q
A-ABC-0054-S
B-ABC-0054
D-ABC-0054

Thank you for your help.
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
This should accomplish the first two:

Code:
Sub test()
Dim startingNumber As Long, timesTorepeat As Long, endingNumber As Long
startingNumber = Application.InputBox("Enter Starting Number:", Type:=1)
timesTorepeat = Application.InputBox("Number of Times to repeat each Number:", Type:=1)
endingNumber = Application.InputBox("Last Number in Sequence:", Type:=1)
With Range("A1:A" & ((endingNumber - startingNumber) * timesTorepeat) + timesTorepeat)
    .Formula = "=""ABC-""&TEXT(-INT(-ROW(A" & (startingNumber * timesTorepeat) - (timesTorepeat - 1) & ")/" & timesTorepeat & "),""0000"")"
    .Value = .Value
End With
End Sub

So in the first sample, start number is 1, times to repeat is 3, end number is 3
Second sample, start number is 50, times to repeat is 4, end number is 52
 
Upvote 0

Forum statistics

Threads
1,214,929
Messages
6,122,315
Members
449,081
Latest member
tanurai

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