• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Run Macros one after another.

saamrat

Member
Hi,

I have 2 macros. First macro refreshes table created by Power Query. The second macro refreshes Pivot table based on the data from power query table.
I tried call function. It refreshes first table. but not the pivot table. If I press the macro button twice, it works. Please help me to refresh both tables at single click. These are my macros;

>>> use code - tags <<<
Code:
'MACRO 1
'-------------

Sub LoadData()
Application.ScreenUpdating = False
Worksheets("Master").ListObjects("Table1_2").Refresh
Sheets("Packing List").Select
Range("C1").Select
Application.ScreenUpdating = True
End Sub

'MACRO 2
'-------------------

Sub Refresh1()
Application.ScreenUpdating = False
Worksheets("Packing List").PivotTables("PivotTable1").PivotCache.Refresh
Range("A:A").EntireRow.RowHeight = 26
Application.ScreenUpdating = True

End Sub
Is there any way to refresh both table in a single click ?
I tried Call Function in the first macro. But not working.
 
Last edited by a moderator:
Thanks for the reply. But it is not working. It works only if I press the button twice.
Is there any other method
 
Code:
'MACRO 1
'-------------

Sub LoadData()
    Application.ScreenUpdating = False
        Worksheets("Master").ListObjects("Table1_2").Refresh
        Sheets("Packing List").Select
        Range("C1").Select
    Application.ScreenUpdating = True

Refresh1

End Sub
 
There is something wrong with your code or your workbook might be corrupted.

Both methods work here.
 
Check the properties for the data connection. Most likely you have it set to allow refreshing in the background. If you turn that off, the code should work (as would a simple refreshall).
 
Back
Top