#1   Report Post  
nc
 
Posts: n/a
Default Pivot table refresh

Private Sub Worksheet_Change(ByVal Target As Range)

ActiveSheet.PivotTables("PivotTable3").PivotCache. Refresh
ActiveSheet.PivotTables("PivotTable1").PivotCache. Refresh

End Sub

I am using the above macro to refresh two pivot tables on the same
worksheet. the problem is when I change a value on the worksheet and the
macro runs, it seems to run as an endless loop. Please help.
  #2   Report Post  
Dave Peterson
 
Posts: n/a
Default

Private Sub Worksheet_Change(ByVal Target As Range)

application.enableevents = false
ActiveSheet.PivotTables("PivotTable3").PivotCache. Refresh
ActiveSheet.PivotTables("PivotTable1").PivotCache. Refresh
application.enableevents = true

End Sub

This tells excel to stop looking for changes, then do the refreshing, then start
looking for changes again.

nc wrote:

Private Sub Worksheet_Change(ByVal Target As Range)

ActiveSheet.PivotTables("PivotTable3").PivotCache. Refresh
ActiveSheet.PivotTables("PivotTable1").PivotCache. Refresh

End Sub

I am using the above macro to refresh two pivot tables on the same
worksheet. the problem is when I change a value on the worksheet and the
macro runs, it seems to run as an endless loop. Please help.


--

Dave Peterson
  #3   Report Post  
nc
 
Posts: n/a
Default

Thanks Dave.

I did not seem to have this problem when the pivot tables were on different
worksheets. Do you still recommend I use application.enableevents = false.

"Dave Peterson" wrote:

Private Sub Worksheet_Change(ByVal Target As Range)

application.enableevents = false
ActiveSheet.PivotTables("PivotTable3").PivotCache. Refresh
ActiveSheet.PivotTables("PivotTable1").PivotCache. Refresh
application.enableevents = true

End Sub

This tells excel to stop looking for changes, then do the refreshing, then start
looking for changes again.

nc wrote:

Private Sub Worksheet_Change(ByVal Target As Range)

ActiveSheet.PivotTables("PivotTable3").PivotCache. Refresh
ActiveSheet.PivotTables("PivotTable1").PivotCache. Refresh

End Sub

I am using the above macro to refresh two pivot tables on the same
worksheet. the problem is when I change a value on the worksheet and the
macro runs, it seems to run as an endless loop. Please help.


--

Dave Peterson

  #4   Report Post  
Dave Peterson
 
Posts: n/a
Default

If you have a worksheet_change event in the worksheet with that other
pivottable, you may want to use it.



nc wrote:

Thanks Dave.

I did not seem to have this problem when the pivot tables were on different
worksheets. Do you still recommend I use application.enableevents = false.

"Dave Peterson" wrote:

Private Sub Worksheet_Change(ByVal Target As Range)

application.enableevents = false
ActiveSheet.PivotTables("PivotTable3").PivotCache. Refresh
ActiveSheet.PivotTables("PivotTable1").PivotCache. Refresh
application.enableevents = true

End Sub

This tells excel to stop looking for changes, then do the refreshing, then start
looking for changes again.

nc wrote:

Private Sub Worksheet_Change(ByVal Target As Range)

ActiveSheet.PivotTables("PivotTable3").PivotCache. Refresh
ActiveSheet.PivotTables("PivotTable1").PivotCache. Refresh

End Sub

I am using the above macro to refresh two pivot tables on the same
worksheet. the problem is when I change a value on the worksheet and the
macro runs, it seems to run as an endless loop. Please help.


--

Dave Peterson


--

Dave Peterson
  #5   Report Post  
nc
 
Posts: n/a
Default

Thanks again Dave.

Does this mean if I have a worksheet_change event in the worksheet but the
pivottable I am refreshing is another worksheet, I do not need to use
application.enableevents.


"Dave Peterson" wrote:

If you have a worksheet_change event in the worksheet with that other
pivottable, you may want to use it.



nc wrote:

Thanks Dave.

I did not seem to have this problem when the pivot tables were on different
worksheets. Do you still recommend I use application.enableevents = false.

"Dave Peterson" wrote:

Private Sub Worksheet_Change(ByVal Target As Range)

application.enableevents = false
ActiveSheet.PivotTables("PivotTable3").PivotCache. Refresh
ActiveSheet.PivotTables("PivotTable1").PivotCache. Refresh
application.enableevents = true

End Sub

This tells excel to stop looking for changes, then do the refreshing, then start
looking for changes again.

nc wrote:

Private Sub Worksheet_Change(ByVal Target As Range)

ActiveSheet.PivotTables("PivotTable3").PivotCache. Refresh
ActiveSheet.PivotTables("PivotTable1").PivotCache. Refresh

End Sub

I am using the above macro to refresh two pivot tables on the same
worksheet. the problem is when I change a value on the worksheet and the
macro runs, it seems to run as an endless loop. Please help.

--

Dave Peterson


--

Dave Peterson



  #6   Report Post  
Dave Peterson
 
Posts: n/a
Default

It could.

I didn't test it, but did it start going into one of those giant loops without
those statements?

nc wrote:

Thanks again Dave.

Does this mean if I have a worksheet_change event in the worksheet but the
pivottable I am refreshing is another worksheet, I do not need to use
application.enableevents.

"Dave Peterson" wrote:

If you have a worksheet_change event in the worksheet with that other
pivottable, you may want to use it.



nc wrote:

Thanks Dave.

I did not seem to have this problem when the pivot tables were on different
worksheets. Do you still recommend I use application.enableevents = false.

"Dave Peterson" wrote:

Private Sub Worksheet_Change(ByVal Target As Range)

application.enableevents = false
ActiveSheet.PivotTables("PivotTable3").PivotCache. Refresh
ActiveSheet.PivotTables("PivotTable1").PivotCache. Refresh
application.enableevents = true

End Sub

This tells excel to stop looking for changes, then do the refreshing, then start
looking for changes again.

nc wrote:

Private Sub Worksheet_Change(ByVal Target As Range)

ActiveSheet.PivotTables("PivotTable3").PivotCache. Refresh
ActiveSheet.PivotTables("PivotTable1").PivotCache. Refresh

End Sub

I am using the above macro to refresh two pivot tables on the same
worksheet. the problem is when I change a value on the worksheet and the
macro runs, it seems to run as an endless loop. Please help.

--

Dave Peterson


--

Dave Peterson


--

Dave Peterson
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
Sheet protection code conflicts with Pivot Table "auto refresh" KG Excel Discussion (Misc queries) 6 December 21st 05 11:16 PM
Change Data In Pivot Table John Calder New Users to Excel 1 July 7th 05 10:41 PM
Pivot table Data refresh SSD1 Excel Worksheet Functions 2 June 17th 05 09:13 PM
Pivot Table Problems Rachel Gonsior Excel Discussion (Misc queries) 3 March 21st 05 07:24 PM
Pivot table refresh Excel GuRu Excel Worksheet Functions 2 February 23rd 05 01:47 AM


All times are GMT +1. The time now is 05:51 AM.

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"