Hi,

I am new t VBA.

I have the below VBA code where a new column is inserted, an identifier number is added and the series is filled till the last value in the adjoining column. What do I do to make the range dynamic?

Columns("A:A").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Range("A1").Select
ActiveCell.FormulaR1C1 = "Unique ID"
Range("B1").Select
Selection.Copy
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
Range("A2").Select
ActiveCell.FormulaR1C1 = "5454000"
Range("A2").Select
Selection.AutoFill Destination:=Range("A2:A40721"), Type:=xlFillSeries
Range("A2:A40721").Select