Hi Forum
Hope all is well. I need some help with debugging a Macro Module.
I downloaded an example spreadsheet from the internet for project planning, and it works great with one exception, as follows:
Sheet1 has two Buttons as follows:
Code as follows
The debugger stops on Application.Goto Reference:="LastRow". Do I need to define LastRow somehow?
As always any help would be greatly appreciated.
Many thanks
Best Regards
Rob
Hope all is well. I need some help with debugging a Macro Module.
I downloaded an example spreadsheet from the internet for project planning, and it works great with one exception, as follows:
Sheet1 has two Buttons as follows:
- Button1 (Label: Insert New Line) - This button enters a new line and copies all the formula etc. and this works fine. You can select any cell and the button adds a line directly below it.
- Button2 (Label: Insert New Line at End) When I select this option I get the dreaded run time error 1004 Reference isnt valid.
Code as follows
Sub InsertNewLine()
Rows(ActiveCell.Row).Select
Selection.Copy
Selection.Insert Shift:=xlDown
End Sub
Rows(ActiveCell.Row).Select
Selection.Copy
Selection.Insert Shift:=xlDown
End Sub
Sub GotoLastCellAndInsertLine()
Application.Goto Reference:="LastRow"
Call InsertNewLine
End Sub
Application.Goto Reference:="LastRow"
Call InsertNewLine
End Sub
Private Sub BtnInsertNewLine_Click()
Call InsertNewLine
End Sub
Call InsertNewLine
End Sub
Private Sub BtnInsertNewLineAtEnd_Click()
Call GotoLastCellAndInsertLine
End Sub
Call GotoLastCellAndInsertLine
End Sub
The debugger stops on Application.Goto Reference:="LastRow". Do I need to define LastRow somehow?
As always any help would be greatly appreciated.
Many thanks
Best Regards
Rob