.ListObject.QueryTable.Refresh triggers error 91

PJDMrEx

New Member
Joined
Jun 25, 2020
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Hi everyone,
I have an excel workbook with 2 powerquery queries that produce 2 tables named "success" and "Fail".
I have 2 buttons which associated codes are

Private Sub Fail_Refresh_Click()
Application.Range("Fail").ListObject.QueryTable.Refresh BackgroundQuery:=False
End Sub

Private Sub Success_Refresh_Click()
Application.Range("success").ListObject.QueryTable.Refresh BackgroundQuery:=False
End Sub

Clicking on success works, clicking on fail returns "Error 91: Object Variable or With Block Variable Not Set"

Any idea what I should check ?

Thank you
Ph.Drouhin
Office 365
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
In cases like this I often use the immediate window to vet the hierarchy of objects by invoking the Name property since just about every object has a name.

?Application.Range("success").Name

Include ? and hit enter at the end of the line. If OK, you'll get the name of the referenced object or property, depending on what you're testing. If it errors, then you know at least one part that is causing trouble. Could be as simple as case sensitivity. If one part works, add more and test again:

?Application.Range("success").ListObject.QueryTable.Name

and so on. In this case I'd say there's nothing left to test after that. You can also know what any property value is by using the property name. It doesn't have to be "Name".
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,244
Members
452,622
Latest member
Laura_PinksBTHFT

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top