I'd like to insert multiple blank rows into my excel data which is thousands of rows long. The amount of blank rows needed to to be input will be from a value in the cell thats activated.
At the moment i have code that only does 1 row which is shown below but its only a start.
Any help would be appreciated.
At the moment i have code that only does 1 row which is shown below but its only a start.
Any help would be appreciated.
VBA Code:
Sub InsertBlankRowsBasedOnCellValue()
Dim Col As Variant
Dim BlankRows As Long
Dim LastRow As Long
Dim R As Long
Dim StartRow As Long
Col = "A"
StartRow = 1
BlankRows = 1
LastRow = Cells(Rows.Count, Col).End(xlUp).Row
Application.ScreenUpdating = False
With ActiveSheet
For R = LastRow To StartRow + 1 Step -1
If .Cells(R, Col) = "1" Then
.Cells(R + 1, Col).EntireRow.Insert Shift:=xlDown
End If
Next R
End With
Application.ScreenUpdating = True
End Sub