I am attempting to create a macro that will run every time a table is updated by adding an additional row to the table. I am basing my solution on the Microsoft article here Run a macro when certain cells change in Excel - Microsoft 365 Apps
In order for their example to work, I need the value of KeyCells to change to the row beneath the table. This is what I have so far, I understand it is certainly not elegant and I welcome any improvements to the syntax as well. My code also doesn't finish the job of actually copying and pasting the data, but figuring out how to actually select it has stumped me before I got that far.
In order for their example to work, I need the value of KeyCells to change to the row beneath the table. This is what I have so far, I understand it is certainly not elegant and I welcome any improvements to the syntax as well. My code also doesn't finish the job of actually copying and pasting the data, but figuring out how to actually select it has stumped me before I got that far.
VBA Code:
Dim LR As Long
LR = Range("A:A").SpecialCells(xlCellTypeLastCell).Row
Dim part1 As String
Dim part2 As String
part1 = "A" & LR
part2 = "F" & LR
Dim copy_area As String
copy_area = (part1 & ":" & part2)
Range(copy_area).Select
Dim KeyCells As Range
Set KeyCells = Range(copy_area)
If Not Application.Intersect(KeyCells, Range(Target.Address))
Is Nothing Then