Consulting

Results 1 to 2 of 2

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

  1. #1
    VBAX Regular
    Joined
    Jan 2017
    Posts
    29
    Location

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

    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...

    Sample 1.xlsm

    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.

  2. #2
    VBAX Regular
    Joined
    Jan 2017
    Posts
    29
    Location
    Found something on Google that worked well!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •