Matthew_Schu
New Member
- Joined
- Apr 17, 2023
- Messages
- 7
- Office Version
- 2016
- Platform
- Windows
Hello!
I am fairly new to VBA and I'm trying to insert a number of rows equal to the value of a number in a cell -1. Then I would like to copy and paste the information that was on the line prior to inserting the blank rows. So far, I've been able to insert a single blank row but nothing past that. The number I'm referencing is in column "U."
I would greatly appreciate any and all help. Thank you.
Dim Col As Variant
Dim BlankRows As Long
Dim LastRow As Long
Dim R As Long
Dim StartRow As Long
Col = "U"
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, Col).EntireRow.Insert Shift:=xlDown
End If
Next R
End With
Application.ScreenUpdating = True
End Sub
I am fairly new to VBA and I'm trying to insert a number of rows equal to the value of a number in a cell -1. Then I would like to copy and paste the information that was on the line prior to inserting the blank rows. So far, I've been able to insert a single blank row but nothing past that. The number I'm referencing is in column "U."
I would greatly appreciate any and all help. Thank you.
Dim Col As Variant
Dim BlankRows As Long
Dim LastRow As Long
Dim R As Long
Dim StartRow As Long
Col = "U"
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, Col).EntireRow.Insert Shift:=xlDown
End If
Next R
End With
Application.ScreenUpdating = True
End Sub