I have the code below to refresh Powerquery and one pivot chart. It works however I have to run twice to be able to refresh both items. Any suggestion how to fix this issue?
Code
Sub RefreshQueries_Click()
ActiveWorkbook.Connections("Query - qryAldiScanData").Refresh
' Application.Wait (Now + TimeValue("0:00:05"))
Call RefreshData
End Sub
Sub RefreshData()
Sheets("Graph").PivotTables("PivotTable1").PivotCache.Refresh
ThisWorkbook.RefreshAll
End Sub