+ Reply to Thread
Results 1 to 3 of 3

VBA: Get a pivot table to filter automatically based on list choice in Active X Combo Box

  1. #1
    Registered User
    Join Date
    02-19-2009
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    10

    VBA: Get a pivot table to filter automatically based on list choice in Active X Combo Box

    Hi all,

    I am a complete beginner with VBA so am sure it's a simple step I am missing, but would appreciate any help you can offer.

    I have a spreadsheet with a ComboBox in cell C3. It's an ActiveX combo box, which allows me to start typing in any part of an item's description, and it will show a drop down list of item descriptions which contain the text I have already started to type.

    On the same spreadsheet, I have a pivot table of data, and I'd like the pivot table to update based on the item selected in the ComboBox in cell 3.

    Through recording a macro (called PivotFilter) of me manually filtering the pivot, and then editing the code slightly to point at cell C3, I have a macro that successfully updates the pivot when I run it manually.

    Please could someone help me to get the macro to run automatically when the user clicks their item description from the drop down list in the ComboBox, or pastes in an item description into the ComboBox?

    Currently I have this code, which is just the 2 subroutines together. Each works individually, but when I put all the code together like this, I can still start typing in the combo box and choose from a drop down list but the filtering doesn't happen.


    Private Sub ComboBox1_Change()
    ComboBox1.ListFillRange = "DropDownList"
    Me.ComboBox1.DropDown

    End Sub


    Sub PivotFilter()
    '
    ' PivotFilter Macro
    '

    '
    ActiveSheet.PivotTables("PivotTable5").PivotFields("DESCRIPTION"). _
    ClearAllFilters
    ActiveSheet.PivotTables("PivotTable5").PivotFields("DESCRIPTION").CurrentPage _
    = Range("C3").Text
    Range("C4").Select
    End Sub


    thanks in advance

    Charlotte
    Last edited by Spiritseeker; 11-02-2015 at 05:39 AM. Reason: Eited to show a more accurate title

  2. #2
    Forum Expert JasperD's Avatar
    Join Date
    05-07-2013
    Location
    Netherlands
    MS-Off Ver
    Excel 2016
    Posts
    1,393

    Re: VBA query: how to assign 2 Subroutines to an Active X combo box

    Perhaps:

    Please Login or Register  to view this content.
    Please click the * below if this helps

  3. #3
    Registered User
    Join Date
    02-19-2009
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: VBA query: how to assign 2 Subroutines to an Active X combo box

    Hi,

    thanks for responding. The code seems to contain an error, and when I debug it, it highlights this code:

    Please Login or Register  to view this content.
    There is no issue with this line of code when I manually run the Macro though?

    thanks

    Charlotte

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 5
    Last Post: 07-29-2015, 03:23 PM
  2. Assign Macro to Active X Button
    By Excel Guy 123 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 09-12-2014, 08:17 AM
  3. Replies: 1
    Last Post: 12-03-2012, 08:55 AM
  4. [SOLVED] can't debug some subroutines in my project, locked subroutines
    By florin_excel in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 11-28-2012, 01:16 PM
  5. [SOLVED] assign macro to activeX combo box
    By Blake 7 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-05-2012, 11:19 AM
  6. Assign named range in worksheet to combo box
    By AppSupportKarl in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-15-2011, 06:38 AM
  7. Assign macro to combo box
    By Mike Stephens in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 09-09-2011, 02:18 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1