Add another line under previous Hello, I have a client that has the following ma
ID: 644179 • Letter: A
Question
Add another line under previous
Hello, I have a client that has the following macro created
Sub AddLine()
'
' AddLine Macro
'
' Keyboard Shortcut: Ctrl+a
'
ActiveWorkbook.Names.Add Name:="marker", RefersToR1C1:="=Sheet1!R32C1"
ActiveWorkbook.Names("marker").Comment = ""
Application.Goto Reference:="blank_line"
Selection.Copy
Application.Goto Reference:="marker"
ActiveSheet.Paste
Range("A33").Select
Application.CutCopyMode = False
ActiveWorkbook.Names("marker").Delete
End Sub
What they would like to do is use the shortcut key CTRL+A to add another line under the previous line. Whenever they enter CTRL+A it writes overtop of the line just created. I hope my explanation makes sense.
Thanks for everyone's help !!
Explanation / Answer
Hi..
Hi,
There's a little bit of guesswork going on here by me but I think this should do what you want.
Just a small point, if I understood what these ranges are I would re-write this without all the goto's and selecting.
Sub AddLine()
' AddLine Macro
' Keyboard Shortcut: Ctrl+a
Dim LastRow As Long
LastRow = Sheets("Sheet1").Cells(Cells.Rows.Count, "A").End(xlUp).Row + 1
ActiveWorkbook.Names.Add Name:="marker", RefersToR1C1:="=Sheet1!R" & LastRow & "C1"
ActiveWorkbook.Names("marker").Comment = ""
Application.Goto Reference:="blank_line"
Selection.Copy
Application.Goto Reference:="marker".
ActiveSheet.Paste.
Application.CutCopyMode = False.
ActiveWorkbook.Names("marker").Delete.
End Sub.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.