VBA Advice on how you would tackle duplicate number sequence

VBA learner ITG

Board Regular
Joined
Apr 18, 2017
Messages
202
Office Version
  1. 365
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:

Some videos you may like

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
53,306
Office Version
  1. 365
Platform
  1. Windows
No need for VBA.
In B2 put =B1
In B3 put =B2+1
Select B2 & B3 & drag down
 

VBA learner ITG

Board Regular
Joined
Apr 18, 2017
Messages
202
Office Version
  1. 365
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.
 

VBA learner ITG

Board Regular
Joined
Apr 18, 2017
Messages
202
Office Version
  1. 365
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]
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
53,306
Office Version
  1. 365
Platform
  1. Windows
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.
 

My Aswer Is This

Well-known Member
Joined
Jul 5, 2014
Messages
17,264
Office Version
  1. 2013
Platform
  1. Windows
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
 

Watch MrExcel Video

Forum statistics

Threads
1,123,337
Messages
5,601,026
Members
414,422
Latest member
acegreen

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
Top