I have a query table in a worksheet, which is imported from another excel file (using the Power Query Editor). The worksheet is the only one in the workbook.
In a VBA procedure inside This workbook module, I try to assign my querytable to a variable:
Private WithEvents QT As QueryTable
Set QT = Activesheet.QueryTables(1)
But I get the error “subscript out of range”. After some investigation, I tried to count the number of querytables in my worksheet:
MsgBox ActiveSheet.QueryTables.Count
and the result was 0 (zero). Therefore, the VBA can’t “find” my table. What am I doing wrong? I am new in the query tables world, so any help is very welcome.