Reputation: 37
I try to use VBA to refresh queries. The following code works while I refer to specified column. However I would like to specify the changing data to named table.
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 4 Then ThisWorkbook.RefreshAll
End Sub
I tried:
Sheets("Sheet1").ListObjects("Table1").Range.Select
but it dosen't work.
Upvotes: 0
Views: 319
Reputation: 166790
This should work:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Application.Intersect(Target, Me.ListObjects("Table1").DataBodyRange) Is Nothing Then
ThisWorkbook.RefreshAll
End If
End Sub
Upvotes: 1