S
SteveDB1
Hi all.
Hope everyone is enjoying their respective memorial day weekend.
I have a large file that I've made, and want to insert a series of rows by
vba.
I thought the following would work, but I've missed something, and I cannot
quite figure out where I've gone wrong.
I've tried a number of variations, and nothing works. I.e., they'll either
only insert one row, but no more, or no rows at all.
I'd thought that some variation of:
for i = 1 to n step X would work, but it hasn't.
Sub InsertRow()
'
' InsertRow Macro
' make this a auto-insert macro to insert my rows for me.
' it'll definitely save time.
Dim MyRange As Range
Set MyRange = Nothing
On Error Resume Next
Set MyRange = Application.InputBox(Prompt:="Pick the row to start at.",
Type:=8).Rows(1)
Workbooks.Application.ScreenUpdating = False
For i = 1 To 4 Step 8
MyRange(i).EntireRow.Insert (xlShiftDown)
Next i
'On Error GoTo 0
'If MyRange Is Nothing Then
'Exit Sub 'user hit cancel.
'End If
Savechanges = True
End Sub
Hope everyone is enjoying their respective memorial day weekend.
I have a large file that I've made, and want to insert a series of rows by
vba.
I thought the following would work, but I've missed something, and I cannot
quite figure out where I've gone wrong.
I've tried a number of variations, and nothing works. I.e., they'll either
only insert one row, but no more, or no rows at all.
I'd thought that some variation of:
for i = 1 to n step X would work, but it hasn't.
Sub InsertRow()
'
' InsertRow Macro
' make this a auto-insert macro to insert my rows for me.
' it'll definitely save time.
Dim MyRange As Range
Set MyRange = Nothing
On Error Resume Next
Set MyRange = Application.InputBox(Prompt:="Pick the row to start at.",
Type:=8).Rows(1)
Workbooks.Application.ScreenUpdating = False
For i = 1 To 4 Step 8
MyRange(i).EntireRow.Insert (xlShiftDown)
Next i
'On Error GoTo 0
'If MyRange Is Nothing Then
'Exit Sub 'user hit cancel.
'End If
Savechanges = True
End Sub