Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default Pivot Table Question

I saw a similar question in an earlier post and tried to use the solution but was not able to get it to work.

I have a pivot table in sheet Table1, workbook Monitor1. My data is in sheet "Data". over the course of the day, I add data and was hoping there was a macro that would expand the data range of the pivot table and refresh the table to reflect the new data.

Thanks in advance for your help.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default Pivot Table Question

Hi,

Assuming that the data feeding your PivotTable has been formatted as a Table called "Table1", you can paste this code to the module for the "Data" sheet (right-click the tab name and click "View Code"). This sub will only fire when you leave the data tab, so if you enter a bunch of data on the Data tab and then click the Table1 tab, this event will fire. If you don't have your data formatted as a table, then comment out that line and uncomment the line below to use currentregion (works best if no blank rows/columns in data).

Hope this helps,

Ben

Code:

Private Sub Worksheet_Deactivate()

With Sheets("Table1").PivotTables(1)
.SourceData = "Table1[#All]" 'Or uncomment next line if not formatted as a table
'.SourceData = "Data!" & Sheets("Data").Range("A1").CurrentRegion.Address(, , xlR1C1)
.PivotCache.Refresh
End With

End Sub
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default Pivot Table Question

On Wednesday, September 12, 2012 4:51:25 PM UTC-4, (unknown) wrote:
Hi, Assuming that the data feeding your PivotTable has been formatted as a Table called "Table1", you can paste this code to the module for the "Data" sheet (right-click the tab name and click "View Code"). This sub will only fire when you leave the data tab, so if you enter a bunch of data on the Data tab and then click the Table1 tab, this event will fire. If you don't have your data formatted as a table, then comment out that line and uncomment the line below to use currentregion (works best if no blank rows/columns in data). Hope this helps, Ben Code: Private Sub Worksheet_Deactivate() With Sheets("Table1").PivotTables(1) .SourceData = "Table1[#All]" 'Or uncomment next line if not formatted as a table '.SourceData = "Data!" & Sheets("Data").Range("A1").CurrentRegion.Address(, , xlR1C1) .PivotCache.Refresh End With End Sub


Thank you very much. That workded well.
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
Pivot Table Question debinnj Excel Discussion (Misc queries) 0 June 18th 08 09:06 PM
Pivot Table Question: SubTotals for 2 of 4 Pivot Tables in same worksheet [email protected] Excel Programming 0 December 19th 06 05:13 PM
Pivot Table question erick-flores Excel Discussion (Misc queries) 6 November 17th 06 10:39 PM
Pivot Table Question : If statment in Pivot Table?? seve Excel Discussion (Misc queries) 2 November 22nd 05 01:00 AM
Pivot Table Question [email protected] Excel Programming 1 December 12th 03 08:11 AM


All times are GMT +1. The time now is 08:10 PM.

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

About Us

"It's about Microsoft Excel"