I have a table that I update with a SQL query called manually via command button. Looking to automate it to trigger immediately when a new row is added. I currently have code to reformat the sheet based on if any cells in the table are changed, but that would cause the function to be called excessively. Any ideas? I thought about defining a static variable for table length on workbook open and comparing whenever the table is changed, but I'm not entirely sure how to do it. Here's what I currently have:
VBA Code:
Sub Worksheet_Change(ByVal Target As Range)
Dim tbl As ListObject: Set tbl = ListObjects(1)
If Not Intersect(tbl.Range, Target) Is Nothing Then
'SQL query
End If