MrNotSoExcellent
New Member
- Joined
- Aug 23, 2023
- Messages
- 1
- Office Version
- 2016
- Platform
- MacOS
I'm looking for help to write a code that allows me to insert a certain amount of rows into a specific range of cells. The code I'm using (I found somewhere while scouring the internet) is the following:
The code works fine when I only need to add say 5 rows but it takes forever to run when I want to insert 60 rows. Does anyone have a solution or just a 'better' code to do this?
Thanks so much!
VBA Code:
Sub InsertARow()
Dim j As Long
Dim r As Range
j = 5
Set r = Range("A1")
Do While r.Value <> ""
Set r = r.Offset(1, 0)
For i = 1 To j
r.Rows.Insert
Next
Loop
End Sub
The code works fine when I only need to add say 5 rows but it takes forever to run when I want to insert 60 rows. Does anyone have a solution or just a 'better' code to do this?
Thanks so much!