Forum Discussion
Pivot table in power query
- 3 years ago
ThisWorkbook.Connections("Combined_Financials_Sector").Refresh
note that Background refresh option should be checked. In the Excel UI, you can access this setting by clicking on "Connections" in the "Data" ribbon, selecting a connection, and clicking on "Properties". The "Enable background refresh" setting is in the dialog box that opens.
Anonymous
The "Run-time error 9: Subscript out of range" typically occurs when the specified object or element does not exist within the collection. In this case, the error is likely due to the fact that there is no connection named "Combined_Financials_Sector" in the workbook connections.
To resolve this error, you should check if the connection name is correct and make sure that the connection exists in the workbook. To verify the connection name, you can follow these steps:
- Open your Excel workbook.
- Click on the "Data" tab in the ribbon.
- Click on "Connections" to view the workbook connections.
- Look for the connection named "Combined_Financials_Sector" in the list of connections. If it's not there, you may have used a different name or the connection might have been deleted.
If you find the correct connection name, you can use the following VBA code to refresh the connection in the background with the "Enable background refresh" option checked:
This code will try to refresh the connection, and if it doesn't find the connection, it will simply resume the code without raising an error. However, it's essential to make sure that the connection name is correct and exists in the workbook.
If you are still encountering the error after verifying the connection name, please double-check the name spelling and ensure that there are no typos or extra spaces in the connection name. Also, make sure that the connection is created before trying to refresh it programmatically.
I checked what you wrote but there is no workbook link.
I checked what you wrote but there is no workbook link.
I am updating the pivot table.
Private Sub CommandButton1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
Sheets("Symbols_Price").Range("Combined_Price_Sector").ListObject.QueryTable.Refresh BackgroundQuery:=True
Worksheets("PT_C").PivotTables("PivotTable1").PivotCache.Refresh
End Sub
It continues to download in the background but I get another error.
Actually, I just need to press "end" for the refresh to finish.