VBA Advice on how you would tackle duplicate number sequence

VBA learner ITG

Active Member
Joined
Apr 18, 2017
Messages
267
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
Good morning,

I have searched the forum high and low for a solution and i now need your advice if possible!

Is there a VBA code that anyone knows of or a forum piost that i can review to sequence the number like below in VBA to be applied in coloumn B until the end of the data in row A?

The sequence has to be in the below format and the number sequence which could be 1000

1
1
2
2
3
3
4
4
etc .........

<tbody>
</tbody>
 
Last edited:

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
No need for VBA.
In B2 put =B1
In B3 put =B2+1
Select B2 & B3 & drag down
 
Upvote 0
Hi Fluff,

this is a sequence that I am trying to build/find a solution in VBA to sequence as part of a larger script.

The sequence needs to be autmated due to the volumes of worksheets being processed.
 
Upvote 0
this code i found sequnces the number like below but not in the format and sequence i need it in

1
2
3
4
5
6
7
8
etc..

but i need it like below

1
1
2
2
3
3
4
4
5
5
6
6
7
7
8
8
etc....

Code:
[COLOR=rgba(0, 0, 0, 0.7)][FONT=&quot]Sub fill_in()[/FONT][/COLOR]
[COLOR=rgba(0, 0, 0, 0.7)][FONT=&quot]Dim i As Integer[/FONT][/COLOR]
[COLOR=rgba(0, 0, 0, 0.7)][FONT=&quot]For i = 0 To WorksheetFunction.CountA(Columns("A:A")) - 1[/FONT][/COLOR]
[COLOR=rgba(0, 0, 0, 0.7)][FONT=&quot]Range("b1").Offset(i, 0).Value = i + 1[/FONT][/COLOR]
[COLOR=rgba(0, 0, 0, 0.7)][FONT=&quot]Next i[/FONT][/COLOR]
[COLOR=rgba(0, 0, 0, 0.7)][FONT=&quot]End Sub[/FONT][/COLOR]
 
Upvote 0
If you record yourself doing what I've suggested, with the macro recorder, you can then clean up the recorded code & modify to suit.
If you need help modifying it, then post your code along with an exact description, of what else needs to be done.
 
Upvote 0
Try this:
Code:
Sub Duplicate_Me()
Application.ScreenUpdating = False
Dim i As Long
Dim x As Long
x = 1
Dim Lastrow As Long
Lastrow = Cells(Rows.Count, "A").End(xlUp).Row
    For i = 1 To Lastrow
        Cells(x, 2).Resize(2).Value = i
        x = x + 2
    Next
Application.ScreenUpdating = False
End Sub
 
Upvote 0

Forum statistics

Threads
1,213,534
Messages
6,114,184
Members
448,554
Latest member
Gleisner2

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