ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Re-run subroutine when pivot page field is changed (https://www.excelbanter.com/excel-programming/399598-re-run-subroutine-when-pivot-page-field-changed.html)

AEROTJK

Re-run subroutine when pivot page field is changed
 
Hello,

I currently have a subroutine that basically executes contiional formats on
a pivot table. I was wondering if there is a way that if a user changes the
page field that I can remove all of the formats and then re-run the routine
for the newly displayed data.

Thanks in advance for your assistance.
John

SeanC UK[_3_]

Re-run subroutine when pivot page field is changed
 
Hi Aerotjk

You can do this. In the module for the worksheet that contains the pivot
table, select Worksheet in the Object drop down, and you should see
PivotTableUpdate in the Procedure drop down. Selecting these will give you a
Sub like this (or you can simply write the code below, in the Worksheet
module):

Private Sub Worksheet_PivotTableUpdate(ByVal Target As PivotTable)

End Sub

You can then write, or call, your routine in here. If there are multiple
Pivot Tables on that sheet then use the Target variable to make sure you have
the right one.

Hope this helps,

Sean.


"AEROTJK" wrote:

Hello,

I currently have a subroutine that basically executes contiional formats on
a pivot table. I was wondering if there is a way that if a user changes the
page field that I can remove all of the formats and then re-run the routine
for the newly displayed data.

Thanks in advance for your assistance.
John



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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com