Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 21st, 2006, 01:17 AM
Registered User
 
Join Date: Feb 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to Wulffman Send a message via MSN to Wulffman
Default Pivot Table Update on DropButtonClick

I am struggling with automagically updating a Pivot Table's fields based upon user selection in a drop box.

I've read the help file and it indicates that the event that I want to use is the object_dropbuttonclick() event.

In trying to implement it, I have the following code in a module in Excel 2k3:

Private Sub Worksheet_DropButtonClick()
    a = Worksheets("BuildQry").Cells(6, 1)
    Sheets("BuildQry").PivotTables("PivotTable2").Pivo tFields("ITDept").CurrentPage = a
    a = Worksheets("BuildQry").Cells(8, 1)
    Sheets("BuildQry").PivotTables("PivotTable4").Pivo tFields("ITName").CurrentPage = a
End Sub

It doesn't seem to matter where I locate the code (in a module, a workbook, or a sheet).

In order to get other cell's drop down list contents to dynamically change (driven from by pivot tables based upon the contents of an initially selected list box), I have to call the macro with a button after I select an item in the first cell's list.

I would like the code to execute as soon as I make a selection from the list, or 'navigate' off of the cell with the validation list.

Please review and advise the errors in my attempts. TIA.

-t



 
Old February 5th, 2015, 12:36 PM
Registered User
 
Join Date: Jun 2011
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default I do it this way.

For anyone else who may want to do this:

I use an intersect event so that when the field is modified, it automatically calls a routine to update the field in the pivot table. The intersect event is on the Worksheet where the pivot table is located.

Code:
 
Private Sub Worksheet_Change(ByVal Target As Range)

If Not Intersect(Target, Range("MonthTr")) Is Nothing Then
    Run "StateSales"
Else
    Exit Sub
End If
                
End Sub

Sub StateSales()
With ActiveSheet.PivotTables("PvtMonthTax").PivotFields("Month")
     .ClearAllFilters
     .PivotFilters.Add Type:=xlCaptionEquals, Value1:=ActiveSheet.Range("MonthTr").Value

     ActiveSheet.PivotTables("PvtMonthTax").PivotCache.Refresh
        
End With

Last edited by Dean45ess; February 5th, 2015 at 01:08 PM..





Similar Threads
Thread Thread Starter Forum Replies Last Post
Editing in Pivot Table brrmsc VBScript 0 November 29th, 2005 01:10 AM
Pivot Table vbsolo Excel VBA 3 November 23rd, 2005 01:28 AM
Pivot Table mikeparams SQL Server 2000 1 February 9th, 2005 10:10 AM
Pivot Table ramdasu Excel VBA 0 October 23rd, 2003 03:16 AM
Pivot Table integrity cmquinn Excel VBA 0 June 23rd, 2003 06:25 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.