+ Reply to Thread
Results 1 to 6 of 6

Pivot Table: Getting Error Message: Sub Defined More Than Once

  1. #1
    Forum Contributor
    Join Date
    02-12-2018
    Location
    TX
    MS-Off Ver
    MS Office 2019
    Posts
    305

    Pivot Table: Getting Error Message: Sub Defined More Than Once

    Hello. I have a macro that is used for hiding slicers (below). I got it using a test sheet. I've reformatted it to try and apply it to the workbook that it's intended to be used for (attached), but I'm getting the following error message:
    Compile Error: Ambiguous Name Detected: Worksheet_PivotTableUpdate
    Would greatly appreciate if someone could look at this and tell me where I'm going wrong. Please and Thank You.
    ***Note: Attached Workbook does not include below macro as my intent was to work all the bugs out first, then apply it to the second sheet***

    Please Login or Register  to view this content.
    Attached Files Attached Files

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,705

    Re: Pivot Table: Getting Error Message: Sub Defined More Than Once

    What sheet module are you trying to put the above code in? If you are trying to put it in BuildMyBOM you will get this error because there is already a Sub there called Worksheet_PivotTableUpdate.

    Attached Workbook does not include below macro as my intent was to work all the bugs out first, then apply it to the second sheet
    If you don't provide the same workbook that is giving you the error, then it is not possible for us to reproduce the error.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Pivot Table: Getting Error Message: Sub Defined More Than Once

    Jumping in on this again.

    I don't know what the issue is. The code you had worked just fine when added to the code on the second sheet.

    I did "clean it up" a bit. There was a way to loop through the slicers because you stuck to a good naming convention for the shape names.

    Please Login or Register  to view this content.
    One spreadsheet to rule them all. One spreadsheet to find them. One spreadsheet to bring them all and at corporate, bind them.

    A picture is worth a thousand words, but a sample spreadsheet is more likely to be worked on.

  4. #4
    Forum Contributor
    Join Date
    02-12-2018
    Location
    TX
    MS-Off Ver
    MS Office 2019
    Posts
    305

    Re: Pivot Table: Getting Error Message: Sub Defined More Than Once

    6StringJazzer: Macro was intended for the second sheet (BuildMyBOM) which currently had a macro in it and basically the issue I was running into was trying to combine the two and getting the error message listed above.

    Dflak: We meet again. Thanks again for your help with on the previous post. I'm multi-tasking here which might be part of the problem. I don't trust myself to work on the final FINAL version without messing it up due to my in-experience, so I have multiple "Test" versions saved from various points in time that I'm using to mess with macros and try and get from A-B.

  5. #5
    Forum Contributor
    Join Date
    02-12-2018
    Location
    TX
    MS-Off Ver
    MS Office 2019
    Posts
    305

    Re: Pivot Table: Getting Error Message: Sub Defined More Than Once

    And just tested it and it seems to be working great. Once again, thanks for your help. You're on the verge of getting a fruit basket or something.

  6. #6
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Pivot Table: Getting Error Message: Sub Defined More Than Once

    I do the same thing. It's not a bad technique as you learn to develop modular code. I have dozens of modules in my bag of tricks. Some of them I never used again, but there are a handful I use daily. The concept of interchangeable parts has been around since the day of Eli Whitney. Many of my programs are "off my shelf" VB with bits and pieces of VBA to tie them together.

    Working on projects such as these helps develop these pieces and I learn some things like: I didn't know you could hide a slicer.

+ 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. [SOLVED] Error message: Run-Time error '1004 '; application-defined or object-defined error
    By Davasu in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-23-2015, 06:52 AM
  2. Replies: 1
    Last Post: 10-22-2015, 05:50 AM
  3. [SOLVED] Pivot table - variable not defined error
    By Ricardo Mass in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-24-2014, 06:39 AM
  4. Pivot table error message but can't find the offending pivot table
    By dcoates in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 01-22-2013, 08:45 AM
  5. Application defined or object defined error when creating a Pivot Table
    By Kaigi in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-02-2009, 05:05 PM
  6. [SOLVED] Pivot Table Error Message
    By Mike in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 07-26-2006, 09:50 AM
  7. Error Message for Pivot Table
    By vicky0512 in forum Excel General
    Replies: 0
    Last Post: 06-26-2006, 03:00 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