Requirement:
The user is trying to now copy row data to the empty rows beneath it up until the next row with data, and then repeat to the end of the data,
Solution:
Before you run the macro, delete all the blank rows in Sheet1.
Sub insertRows()
Application.ScreenUpdating = False
Dim LastRow As Long
LastRow = Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
Dim x As Long
For x = LastRow To 4 Step -1
Rows(x).EntireRow.Copy
Rows(x + 1).Resize(Cells(x, "J").Value).Insert
Next x
Application.CutCopyMode = False
Application.ScreenUpdating = True
End Sub
Obtained from the OzGrid Help Forum.
Solution provided by Mumps.
See also: Index to Excel VBA Code and Index to Excel Freebies and Lesson 1 - Excel Fundamentals and Index to how to… providing a range of solutions and Index to new resources and reference sheets
See also:
| How to loop through different ranges |
| How to cut, copy and insert on a loop |
| How to turn one operation into a loop in VBA |
| How to use looping to delete cells of similar value |
Click here to visit our Free 24/7 Excel/VBA Help Forum where there are thousands of posts you can get information from, or you can join the Forum and post your own questions.