Balloonman4343
New Member
- Joined
- Apr 13, 2021
- Messages
- 2
- Office Version
- 2016
- Platform
- Windows
I've created a macro which adds a line whilst copying the format and formulas of the above line. This works fine and the code is below:
Sub New_Line()
Rows("7:7").Select'
'Selection.Insert Shift:=xlDown,
CopyOrigin:=xlFormatFromLeftOrAbove Rows("6:6").
Select Selection.Copy Rows("7:7").
Select Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False Application.CutCopyMode = False Range("G6:T6").
Select Selection.AutoFill Destination:=Range("G6:T7"), Type:=xlFillDefault Range("G7:T7").Select
ActiveWindow.ScrollColumn = 1
End Sub
However, I want to add another line under the line I have just created using the macro above and so on, so that this can be a continuous thing and to also keep a running total using the formulas from the previously added line above (hope that makes sense). I can see where the issue is in the coding above, the macro will always add the line to row 7 and copy the formula/format from row 6. I've tried adding a +1 but no success, I considered a loop but that would confuse the macro run. Can anyone please help?
Thanks in advance
Sub New_Line()
Rows("7:7").Select'
'Selection.Insert Shift:=xlDown,
CopyOrigin:=xlFormatFromLeftOrAbove Rows("6:6").
Select Selection.Copy Rows("7:7").
Select Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False Application.CutCopyMode = False Range("G6:T6").
Select Selection.AutoFill Destination:=Range("G6:T7"), Type:=xlFillDefault Range("G7:T7").Select
ActiveWindow.ScrollColumn = 1
End Sub
However, I want to add another line under the line I have just created using the macro above and so on, so that this can be a continuous thing and to also keep a running total using the formulas from the previously added line above (hope that makes sense). I can see where the issue is in the coding above, the macro will always add the line to row 7 and copy the formula/format from row 6. I've tried adding a +1 but no success, I considered a loop but that would confuse the macro run. Can anyone please help?
Thanks in advance