+ Reply to Thread
Results 1 to 3 of 3

Combo Box Change Event with Macro Call

  1. #1
    Registered User
    Join Date
    07-20-2011
    Location
    Oakland, CA USA
    MS-Off Ver
    Excel 2003
    Posts
    4

    Combo Box Change Event with Macro Call

    First post ever.

    I have a macro (Excel 2003) which refreshes a number of pivot tables based on values in three different cells on a separate worksheet. The macro runs fine when fired independently.

    I added a dropdown list to select values for each of these cells and triggered the firing of my macro using a worksheet change event. This works perfectly.

    What I really want is to use three combo boxes to select the values and to trigger the macro using a combobox change event. When I try this, however the macro bombs on the third line of code. I'm pretty new to VBA and I've never tried to use the combobox change event so I may be missing something really basic.

    Here's the code I'm using for the change event. (The macro name is "RefreshPivots"). I've placed the following code on the worksheet object (within the VBA editor) for the worksheet where the combo box was placed. Again the macro runs perfectly when I run it on its own which leads me to suspect that there's something wrong with my combox change event code.

    Please Login or Register  to view this content.
    Here's a snippet of the macro code which refreshes the first of several pivot tables:

    Please Login or Register  to view this content.


    The line of code (executable line3) where the macro fails is:
    Please Login or Register  to view this content.
    The error is:

    Run-time error '1004'
    Unable to get the PivotFields property of the PivotTable class

    Thanks for any help you can offer
    Last edited by Bosco6; 07-21-2011 at 02:46 PM.

  2. #2
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Combo Box Change Event with Macro Call

    Hi Bosco6 and welcome to the forum. Please take a moment to read the forum rules located here and wrap your code in code tags as per Rule #3. Once you do that, someone will be able to help you.
    If you're happy with someone's help, click that little star at the bottom left of their post to give them Reps.

    ---Keep on Coding in the Free World---

  3. #3
    Registered User
    Join Date
    07-20-2011
    Location
    Oakland, CA USA
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Combo Box Change Event with Macro Call

    Thanks for that. Proper convention for pasting code into my posts is duly noted.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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