PDA

View Full Version : [SOLVED:] Fill Series of Sequential Numbers in Column A Based on Last Value in Column B - VBA



CC268
01-24-2017, 09:32 AM
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...

18119


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

See example spreadsheet for clarification. Notice 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.

CC268
01-24-2017, 09:51 AM
Found something on Google that worked well!