External Data (MSQuery) AND Using and Auto_Open Macro

Poppy

New Member
Joined
Apr 29, 2002
Messages
1
This is really two problems: A Pivot Table won't refresh, and an Auto_Open Macro won't run.

I have a worksheet linked to a table in MS Access. I created it by "Get External Data" - "MSAccess", etc., and ultimately selecting "Update on Open" so that each time the worksheet is opened, the data is refreshed. THIS PART WORKS.

However, I created a Pivot Table based on that worksheet, and although I have checked the box in the Pivot Table "OPTIONS" to "Refresh on Open", it does not refresh. As a work-around, I tried to create an Auto_Open Macro that has just a couple of lines of code-- to select the worksheet, go to a legitimate cell, and refresh the Pivot Table. The macro doesn't appear to be running when the workbook is opened. But if I run the macro after the worksheet is open, the macro commands run as intended. ANY HELP WOULD BE APPRECIATED. Thank you.
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
Hi
Your remove the refresh on open on both the query and the pivottabel and then use the auto_open macro to refresh both.
I thing the problem is that your pivottable refreshes before your query, so you will never have new results in the pivottable.

Sub auto_open()
Selection.QueryTable.Refresh BackgroundQuery:=False
ActiveSheet.PivotTables("Pivottabel1").RefreshTable
End Sub

regards Tommy
 
Upvote 0
I agree with the post above, pivots are fast ODBC is slow i always tell guys getthe data then minipulte it NOT before or both together


i would have two scipts ...
 
Upvote 0

Forum statistics

Threads
1,214,590
Messages
6,120,423
Members
448,961
Latest member
nzskater

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