Macro to auto refresh pivot table on a filter

myquan14

New Member
Joined
Apr 22, 2011
Messages
8
In excel 2007, I have created a pivot table that uses a weight calculation in the data set and a calculated field to show weighted values in the pivot table.

My data set contains multiple time frames, for example 2011-1H or 2011-1Q. I am only using halves and quarters - which will determine my data set weights.

Time frame is used as my 'Report Filter' in my pivot table. When time frame is filtered in my pivot table to either half or quarter my weight calculation within my data set updates accordingly using an 'if' statement.

Here is my issue: I would like to automatically refresh my pivot table after I have filtered my time frame field. (The reason I need to do this is because my weight calculation changes depending on the time frame shown and my totals do not add to 100 unless i refresh the table.) As of now, I am only able to do so by manually refreshing the pivot table. I have created a button that refreshes the entire workbook but this isn't quite the result i want. This workbook is going to be used by a number of people and want to limit the amount of steps needed to manage the book.

In summary: I would like to refresh a pivot table automatically after a field filter.

Any thoughts? Thanks in advance.
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Hello & Welcome to the board,

This could work...change the Pivot Table name...

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    Application.EnableEvents = False
    Me.PivotTables("PivotTable1").PivotCache.Refresh
    Application.EnableEvents = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,592
Messages
6,179,789
Members
452,942
Latest member
VijayNewtoExcel

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