Fill Series of Sequential Numbers in Column A Based on Last Value in Column B - VBA

CC268

Active Member
Joined
Mar 7, 2016
Messages
328
This should be fairly straight forward, but I am having a tough time getting it figured out. I simply want to insert a blank Column A and then fill in Column A with a series of sequential numbers all the way down until the last value in Column B.

Here is what I have so far...

Code:
<code style="margin: 0px; padding: 0px; font-style: inherit; font-weight: inherit; line-height: 12px;">Sub FillSeries()

    Columns("A:A").Select
    Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove

    'r = row, c = column
    Application.Goto Reference:="R1C2" 
    With Worksheets("Sheet1")
    LastRow = .Cells(Rows.Count, "B").End(xlUp).Row
    .Range("B1:B" & LastRow).Select

    End With</code>

Cell B2 will always be blank so we need to make sure we are using the .End(xlUp).Row function to make sure the code isn't stopping at cell B2 and is capturing the entire range of Column B.

Unfortunately I can't use file sharing sites here at work, so I am unable to upload a sample. However, here is a photo to give you an idea of what I want done.

xVhLA3ETnhKkVYoi8
 
Last edited:

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.

Forum statistics

Threads
1,224,823
Messages
6,181,178
Members
453,021
Latest member
Justyna P

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