Macro to update pivot tables on hidden sheets

U

urbanecho

Hi,

Is it possible to run a macro to update pivot tables on hidden sheets
in a workbook.

I tried recording the macro manually when the sheets were visible and
all worked fine, but when I then hid the sheets, the macro breaks with
the error "Select method of Worksheet Class failed"

Any help appreciated,
Ian
 
H

Harald Staff

Hi Ian

This should work -replace the sheet name:

Sub UpdateThem()
Dim iP As Integer
Application.DisplayAlerts = False
For iP = 1 To Sheets("HiddenTables").PivotTables.Count
Sheets("HiddenTables").PivotTables(iP).RefreshTable
Next
Application.DisplayAlerts = True
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top