VBA doesn't refresh Pivot Table

TheHack22

Board Regular
Joined
Feb 3, 2021
Messages
121
Office Version
  1. 365
Platform
  1. Windows
  2. Mobile
Hi VBA Experts,'

I have this simple VBA to refresh a single Pivot Table in a file, but it doesn't work.
This is a small part of many steps in my process. The PVT Data doesn't refresh and thus, this throws out the other steps.

Sub Workbook_RefreshAll()
Sheets("PVT").Activate
ActiveSheet.Range("C6").Select
ActiveWorkbook.RefreshAll
End Sub

Can someone say why this wouldn't work?
Imran
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
at the moment, this macro runs, is the activeworkbook the workbook you want ?
Are you sure this macro is called ?
 
Upvote 0
In addition to BSALV's questions, is the pivot data range dynamic as in using a table range and picking any additional rows ?
And another possibility, is the pivot based on a Power Query Table ?
 
Upvote 0
at the moment, this macro runs, is the activeworkbook the workbook you want ?
Are you sure this macro is called ?
Hi @BSALV

Thanks for your response. Yes, the workbook is the Activework, which becomes active with the preceding Sub.
Yes to the second question too.
Imran
 
Upvote 0
In addition to BSALV's questions, is the pivot data range dynamic as in using a table range and picking any additional rows ?
And another possibility, is the pivot based on a Power Query Table ?
@Alex Blakenburg

Thanks for your question.
I just realized that my data source is not dynamic (Not in a Table Format).
There is no Power Query in this process.

Imran
 
Upvote 0
I just realized that my data source is not dynamic (Not in a Table Format).

Are you able to use a table and then use the table name as the data source ? and does that fix your issue ?

Note: Please give the Table a meaningful name and not just Table1. I tend to prefix my table names with "tbl" that way the tables group together in the name manager and if you start typing =tbl in the formula bar you get a list of your tables.
 
Upvote 0
Are you able to use a table and then use the table name as the data source ? and does that fix your issue ?

Note: Please give the Table a meaningful name and not just Table1. I tend to prefix my table names with "tbl" that way the tables group together in the name manager and if you start typing =tbl in the formula bar you get a list of your tables.
@Alex Blakenburg
Thanks very much for this tip. I formatted the data source as a table and that solved the issue. :)
Imran
 
Upvote 0

Forum statistics

Threads
1,214,432
Messages
6,119,468
Members
448,900
Latest member
Fairooza

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top