I have a correctly connected query table on a worksheet called "SQL Data" that I can refresh manually no problem.
However, when I run this VBA code I get the following error:
Dim ws As Worksheet
Set ws = Worksheets("SQL Data")
'Refresh the SQL Table'
Worksheets("SQL Data").QueryTables(1).Refresh
>>ERROR: Subscript out of range
On further inspection using the Locals pane, I found the count of the object QueryTables for ws is 0
Why is the table not being added into QueryTables?
However, when I run this VBA code I get the following error:
Dim ws As Worksheet
Set ws = Worksheets("SQL Data")
'Refresh the SQL Table'
Worksheets("SQL Data").QueryTables(1).Refresh
>>ERROR: Subscript out of range
On further inspection using the Locals pane, I found the count of the object QueryTables for ws is 0
Why is the table not being added into QueryTables?