Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 96
Default refresh linked query

i have a pivot table in an excel sheet that is linked to an access database.
i would like to program a macro to refresh the pivot table. i thought the
following would work, but it does not:

FinalRowFRONT = Cells(Cells.Rows.Count, "A").End(xlUp).Row
Range("a" & FinalRowFRONT).Select
Selection.QueryTable.Refresh BackgroundQuery:=False

how do i get the pivot table to refresh?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 464
Default refresh linked query

The macro recorder is you friend :)



--
Regards
Dave Hawley
www.ozgrid.com
"joemeshuggah" wrote in message
...
i have a pivot table in an excel sheet that is linked to an access
database.
i would like to program a macro to refresh the pivot table. i thought the
following would work, but it does not:

FinalRowFRONT = Cells(Cells.Rows.Count, "A").End(xlUp).Row
Range("a" & FinalRowFRONT).Select
Selection.QueryTable.Refresh BackgroundQuery:=False

how do i get the pivot table to refresh?


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 96
Default refresh linked query

i actually used the recorder to get the snippet "Selection.QueryTable.Refresh
BackgroundQuery:=False"...the only problem is i have a few different queries
to refresh that have variable starting points, which is why i used the
finalrow variable. the refresh only works for the range where the macro is
recorded. when i try using the variable range, i get an error.

"ozgrid.com" wrote:

The macro recorder is you friend :)



--
Regards
Dave Hawley
www.ozgrid.com
"joemeshuggah" wrote in message
...
i have a pivot table in an excel sheet that is linked to an access
database.
i would like to program a macro to refresh the pivot table. i thought the
following would work, but it does not:

FinalRowFRONT = Cells(Cells.Rows.Count, "A").End(xlUp).Row
Range("a" & FinalRowFRONT).Select
Selection.QueryTable.Refresh BackgroundQuery:=False

how do i get the pivot table to refresh?


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 96
Default refresh linked query

pulled this from your main site...going to give this a try first thing monday
morning...cant wait!

Dim ws As Worksheet
Dim qs As QueryTable
For Each ws In Worksheets
For Each qs In ws.QueryTables
qs.Refresh (False)
Next qs
Next ws


"joemeshuggah" wrote:

i actually used the recorder to get the snippet "Selection.QueryTable.Refresh
BackgroundQuery:=False"...the only problem is i have a few different queries
to refresh that have variable starting points, which is why i used the
finalrow variable. the refresh only works for the range where the macro is
recorded. when i try using the variable range, i get an error.

"ozgrid.com" wrote:

The macro recorder is you friend :)



--
Regards
Dave Hawley
www.ozgrid.com
"joemeshuggah" wrote in message
...
i have a pivot table in an excel sheet that is linked to an access
database.
i would like to program a macro to refresh the pivot table. i thought the
following would work, but it does not:

FinalRowFRONT = Cells(Cells.Rows.Count, "A").End(xlUp).Row
Range("a" & FinalRowFRONT).Select
Selection.QueryTable.Refresh BackgroundQuery:=False

how do i get the pivot table to refresh?


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 464
Default refresh linked query

Cool. Why not set the QueryTable Properties to automatically Refresh every x
minutes or upon open?




--
Regards
Dave Hawley
www.ozgrid.com
"joemeshuggah" wrote in message
news:31C41AF9-DD10-4F
...
pulled this from your main site...going to give this a try first thing
monday
morning...cant wait!

Dim ws As Worksheet
Dim qs As QueryTable
For Each ws In Worksheets
For Each qs In ws.QueryTables
qs.Refresh (False)
Next qs
Next ws


"joemeshuggah" wrote:

i actually used the recorder to get the snippet
"Selection.QueryTable.Refresh
BackgroundQuery:=False"...the only problem is i have a few different
queries
to refresh that have variable starting points, which is why i used the
finalrow variable. the refresh only works for the range where the macro
is
recorded. when i try using the variable range, i get an error.

"ozgrid.com" wrote:

The macro recorder is you friend :)



--
Regards
Dave Hawley
www.ozgrid.com
"joemeshuggah" wrote in
message
...
i have a pivot table in an excel sheet that is linked to an access
database.
i would like to program a macro to refresh the pivot table. i
thought the
following would work, but it does not:

FinalRowFRONT = Cells(Cells.Rows.Count, "A").End(xlUp).Row
Range("a" & FinalRowFRONT).Select
Selection.QueryTable.Refresh BackgroundQuery:=False

how do i get the pivot table to refresh?




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 236
Default refresh linked query

Do you want to refresh a QueryTable or a PivotTable? I'm not sure you
can refresh PivotTable by refreshing QueryTable.

For PivtTables i usually use something like this:
Workbooks(1).PivotCaches(1).Refresh
or
Worksheets(1).PivotTables(1).PivotCache.Refresh
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Refresh Query Table causing debug error with Background Refresh pr Gum Excel Programming 2 March 12th 09 10:08 PM
How can I 'Enable Automatic Refresh' for Query Refresh by default Anand Deshpande Setting up and Configuration of Excel 0 December 10th 06 04:47 AM
Query Refresh-Enable Automatic Refresh Dialogue Box Terri Excel Discussion (Misc queries) 0 May 6th 05 08:21 PM
Timing of automatic query refresh and macro pivot table refresh dutty Excel Programming 2 December 1st 04 07:19 PM
Excel does not close from VB!! (when i refresh Refresh query with BackgroundQuery:=False) Anant[_2_] Excel Programming 1 August 6th 03 04:22 AM


All times are GMT +1. The time now is 09:58 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"