All,
I want my formula to insert X amount of rows as the value in column 9 states. (E.g. if row 2 column 9 had value = 3, then I want to run the macro to insert 3 + 1 rows) Currently its putting a value in every row of column 9.
I want my formula to insert X amount of rows as the value in column 9 states. (E.g. if row 2 column 9 had value = 3, then I want to run the macro to insert 3 + 1 rows) Currently its putting a value in every row of column 9.
VBA Code:
Sub InsertRow()
LastRow = Worksheets("Sheet1").Cells(Rows.Count, 9).End(xlUp).Row
For i = LastRow To 2 Step by - 1
A = Worksheets("Clinic & Resource Alignment").Cells(i, 9).Value
For j = 1 To A
Worksheets("Sheet1").Rows(i + 1).Select
Selection.Insert Shift:=xlDown
Next
Next
Range("G2:J2").Select
Selection.AutoFill Destination:=Range("G2:J240"), Type:=xlFillDefault
Range("G2:J240").Select
Worksheets("Sheet1").Cells(1, 1).Select
End Sub