Macros to generate sequentially numbers with dynamic input and output

paneliyadhruv

New Member
Joined
May 21, 2018
Messages
36
Dear all, I need help to include dynamic range in below macro.

In my sheet1 in cells D2 having start no 1 and E2 having end no 10. Then next range D3 having start no 21 and E3 having end no 30 till down for both columns D25 to E25. I need output of each range cell in columns start from AA, AB, AC and so on till all range end.
Need modification in above code to include range from two columns and output of each range in separate columns.

Thank you very much to all in advance.

Code:
[COLOR=#E56717][FONT=Consolas][B]Sub[/B][/FONT][/COLOR][COLOR=#141414][FONT=Consolas] FillIt()[/FONT][/COLOR]
[COLOR=#151B8D][FONT=Consolas][B]Dim[/B][/FONT][/COLOR][COLOR=#141414][FONT=Consolas] i [/FONT][/COLOR][COLOR=#151B8D][FONT=Consolas][B]As[/B][/FONT][/COLOR][COLOR=#F660AB][FONT=Consolas][B]Long[/B][/FONT][/COLOR][COLOR=#141414][FONT=Consolas], j [/FONT][/COLOR][COLOR=#151B8D][FONT=Consolas][B]As[/B][/FONT][/COLOR][COLOR=#F660AB][FONT=Consolas][B]Long[/B][/FONT][/COLOR]

[COLOR=#141414][FONT=Consolas]i = InputBox([/FONT][/COLOR][COLOR=#800000][FONT=Consolas]"Enter initial"[/FONT][/COLOR][COLOR=#141414][FONT=Consolas])[/FONT][/COLOR]
[COLOR=#141414][FONT=Consolas]j = InputBox([/FONT][/COLOR][COLOR=#800000][FONT=Consolas]"Ticket number"[/FONT][/COLOR][COLOR=#141414][FONT=Consolas])[/FONT][/COLOR]

[COLOR=#8D38C9][FONT=Consolas][B]With[/B][/FONT][/COLOR][COLOR=#141414][FONT=Consolas] Sheets([/FONT][/COLOR][COLOR=#800000][FONT=Consolas]"Sheet1"[/FONT][/COLOR][COLOR=#141414][FONT=Consolas]).Range([/FONT][/COLOR][COLOR=#800000][FONT=Consolas]"a1"[/FONT][/COLOR][COLOR=#141414][FONT=Consolas])[/FONT][/COLOR]
[COLOR=#141414][FONT=Consolas]        .Value = i[/FONT][/COLOR]
[COLOR=#141414][FONT=Consolas]        .AutoFill .Resize(j - I + 1, 1), xlFillSeries[/FONT][/COLOR]
[COLOR=#8D38C9][FONT=Consolas][B]End[/B][/FONT][/COLOR][COLOR=#8D38C9][FONT=Consolas][B]With[/B][/FONT][/COLOR]

[COLOR=#8D38C9][FONT=Consolas][B]End[/B][/FONT][/COLOR][COLOR=#E56717][FONT=Consolas][B]Sub[/B][/FONT][/COLOR]

 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Code:
Sub FillIt()
Dim rng As Range, d As Range, cel As Range
Set rng = Range([D2], Cells(Rows.Count, "D").End(xlUp))
Set d = [Z2]
For Each cel In rng
    Set d = d(1, 2)
    d = cel
    d.AutoFill d.Resize(cel(1, 2) - cel + 1), xlFillSeries
Next
End Sub
 
Upvote 0
To add prefix "A-" (for example) :
Code:
Sub FillIt()
Dim rng As Range, d As Range, cel As Range
Set rng = Range([D2], Cells(Rows.Count, "D").End(xlUp))
Set d = [Z2]
For Each cel In rng
    Set d = d(1, 2)
    d = cel
    d.AutoFill d.Resize(cel(1, 2) - cel + 1), xlFillSeries
[COLOR=#0000ff]    d.Resize(cel(1, 2)).NumberFormat = """A-""0"[/COLOR]
Next
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,888
Messages
6,175,213
Members
452,618
Latest member
Tam84

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