Zerrets
Zerrets

Reputation: 53

Analyze and update dynamic table macro VBA

I'm trying to make a macro to analyze and update the dynamic table located in the second sheet of the workbook ("TD"), i made a macro but it displays the error '1004' ERROR DEFINED BY THE APPLICATION OR OBJECT, hope you can help me.

Dim wsTD As Worksheet
Dim wbWs As Workbook

Set wbWs = ActiveWorkbook
Set wsTD = wbWs.Worksheets("TD")
wbWs.PivotTables(“TablaDinámica1”).PivotCache.Refresh
wbWs.PivotTables(“TablaDinámica2”).PivotCache.Refresh

Upvotes: 1

Views: 960

Answers (1)

Pᴇʜ
Pᴇʜ

Reputation: 57753

You are trying to find your pivot table in a workbook wbWs not in a worksheet wsTD. Change it to:

wsTD.PivotTables("TablaDinámica1").PivotCache.Refresh
wsTD.PivotTables("TablaDinámica2").PivotCache.Refresh

Upvotes: 3

Related Questions