GIngerlomax
Board Regular
- Joined
- May 20, 2016
- Messages
- 59
Hi there any help will be greatly appreciated.
I need to add a new Row so that it copies all formula and formats from above. Is there a way of making it auto so when they select "Insert new row" the macro automatically does it?
I have found some code on here to make it work via a button but nothing seem to happen?
Sub Loop_InsertRowsandFormulas()
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:=7, Type:=1) 'Default for 1 row, type 1 is number
If firstrw = False Then Exit Sub
End If
Cells(firstrw, "A").Select
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
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
...
I need to add a new Row so that it copies all formula and formats from above. Is there a way of making it auto so when they select "Insert new row" the macro automatically does it?
I have found some code on here to make it work via a button but nothing seem to happen?
Sub Loop_InsertRowsandFormulas()
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:=7, Type:=1) 'Default for 1 row, type 1 is number
If firstrw = False Then Exit Sub
End If
Cells(firstrw, "A").Select
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
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
...