0

I have my report set to refresh a Query, then filldown a column that already exists with a formula that is already at the beginning of the column, then refresh the pivot table that references the query table.

For some reason, I have to run the Macro Twice (Which I have in the form of a button) and I really don't want to run it twice.

Sub Runthrough()
'
' Runthrough Macro
'

'
    ActiveWorkbook.Connections("Query - Purchasereceipt").Refresh
    Range("Purchasereceipt[[Grade]]").FillDown
    Sheets("Pivot Table").PivotTables("PivotTable1").PivotCache.Refresh

End Sub

Thoughts?

Community
  • 1
  • 1
Duthreal
  • 11
  • 4
  • What happens after you run it for the first time? Does it start refreshing the query? Can you see "Running background query" in your statusbar? If yes, then maybe problem is in the fact that it takes some time to perform the refresh and while excel is busy getting the data you macro continues to run so it doesnt fill down anything, because at that time it still has the same number of lines as before. – Pavel_V Mar 07 '18 at 13:49
  • It refreshes the query and it fills down, but it doesnt refresh the pivot table unless I run the macro twice, I tried an application wait command and it just waited and still did not update the pivot table until the second time running the macro. – Duthreal Mar 09 '18 at 19:38
  • maybe check the accepted answer here https://stackoverflow.com/questions/16222091/refresh-both-the-external-data-source-and-pivot-tables-together-within-a-time-sc – Pavel_V Mar 13 '18 at 08:28

0 Answers0