Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Rob Rob is offline
external usenet poster
 
Posts: 234
Default Attaching macro to a pivot table drop down

Hi - I'm wondering if I can attach a macro to one of the
drop down fields in my pivot table. IE - when I
choose "Yes" from one of my drop down fields in my pivot
table, I want to attach a macro to this action...any help
is appreciated!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,979
Default Attaching macro to a pivot table drop down

To run a macro when the page field is changed, use code similar to the
following, where the page field is named "Region" --

'========================================
Dim mvPivotPageValue As Variant

Private Sub Worksheet_Calculate()
'variation on code by Robert Rosenberg 2000/01/11
''I use a module level variable (see above) to keep track of
''the last selection from the Page Field.
''This routine was place in the Worksheet
''containing the PivotTable's code module.
Dim pvt As PivotTable

Set pvt = ActiveSheet.PivotTables(1)
If LCase(pvt.PivotFields("Region").CurrentPage) _
< LCase(mvPivotPageValue) Then
Application.EnableEvents = False
mvPivotPageValue = _
pvt.PivotFields("Region").CurrentPage
'your macro name here
Application.EnableEvents = True
End If
End Sub
'==============================================

Rob wrote:
Hi - I'm wondering if I can attach a macro to one of the
drop down fields in my pivot table. IE - when I
choose "Yes" from one of my drop down fields in my pivot
table, I want to attach a macro to this action...any help
is appreciated!



--
Debra Dalgleish
Excel FAQ, Tips & Book List
http://www.contextures.com/tiptech.html

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 drop down Bhanji Excel Discussion (Misc queries) 1 November 1st 07 12:14 AM
Pivot Table Drop down Dale Hagan Charts and Charting in Excel 2 July 23rd 07 07:20 PM
Attaching a 2 item list to a cell / drop-down? Enrique Mahecha Excel Discussion (Misc queries) 8 December 22nd 05 06:30 PM
Sorting pivot table drop-down Joyce Excel Discussion (Misc queries) 1 May 23rd 05 11:50 PM
Attaching drop down to macro pvdalen Excel Programming 2 May 27th 04 02:44 PM


All times are GMT +1. The time now is 07:01 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"