GIngerlomax
Board Regular
- Joined
- May 20, 2016
- Messages
- 59
Trying to get my insert new row button to work Any help would be amazing!!
First i select the Row.
Dim vRows As Long
Dim firstrw As Long
If firstrw = 0 Then
firstrw = Application.InputBox(prompt:="Indicate under which row you want the macro to begin inserting rows. " _
, Title:="Start Row", Default:=1, Type:=1) 'Default for 1 row, type 1 is number
If firstrw = False Then Exit Sub
End If
Cells(firstrw, "A").Select
Then Select the amount of Rows.
ActiveCell.EntireRow.Select
If vRows = 0 Then
vRows = Application.InputBox(prompt:="How many rows do you want to add? ", Title:="Add Rows", Default:=1, Type:=1)
If vRows = False Then Exit Sub
End If
Then copy down formula from above.
Do Until ActiveCell.Value = ""
ActiveCell.EntireRow.Select
Selection.Resize(rowsize:=2).Rows(2).EntireRow.Resize(rowsize:=vRows).Insert Shift:=xlDown
Selection.Resize(vRows, Selection.Columns.Count - 1).Offset(1, 1).SpecialCells(xlCellTypeConstants).ClearContents
ActiveCell.Offset(vRows + 1, 0).Activate
Loop
End Sub
But it does not seem to be working. I get an 400 error
First i select the Row.
Dim vRows As Long
Dim firstrw As Long
If firstrw = 0 Then
firstrw = Application.InputBox(prompt:="Indicate under which row you want the macro to begin inserting rows. " _
, Title:="Start Row", Default:=1, Type:=1) 'Default for 1 row, type 1 is number
If firstrw = False Then Exit Sub
End If
Cells(firstrw, "A").Select
Then Select the amount of Rows.
ActiveCell.EntireRow.Select
If vRows = 0 Then
vRows = Application.InputBox(prompt:="How many rows do you want to add? ", Title:="Add Rows", Default:=1, Type:=1)
If vRows = False Then Exit Sub
End If
Then copy down formula from above.
Do Until ActiveCell.Value = ""
ActiveCell.EntireRow.Select
Selection.Resize(rowsize:=2).Rows(2).EntireRow.Resize(rowsize:=vRows).Insert Shift:=xlDown
Selection.Resize(vRows, Selection.Columns.Count - 1).Offset(1, 1).SpecialCells(xlCellTypeConstants).ClearContents
ActiveCell.Offset(vRows + 1, 0).Activate
Loop
End Sub
But it does not seem to be working. I get an 400 error