+ Reply to Thread
Results 1 to 4 of 4

Assigning pivot filter that doesn't exist breaks macro

  1. #1
    Forum Contributor
    Join Date
    01-09-2016
    Location
    USA,USA
    MS-Off Ver
    2016
    Posts
    1,192

    Assigning pivot filter that doesn't exist breaks macro

    I have a macro setting pivot filters, but it fails if that filter isn't available. I need to just make it skip that filter but resume error does not work. This is the two macros, it is in of chain of several, but the first macro is what sets the dates and the second is what sets the filter and is what is failing. I'd LOVE to get rid of the dates and just tell the pivot to select the previous week but that is beyond me. I'll be happy right now if I can just get the macro to not error out.




    Please Login or Register  to view this content.

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

    Re: Assigning pivot filter that doesn't exist breaks macro

    The way I handle this is to use a helper cell in the spreadsheet to test if it filter is available. I use COUNTIF and if it's zero, I can't apply the filter, so I skip over it in the code.

    Also, you cannot have all the items set to false. What you have to do is turn everything on, and then turn off what you don't want. You can't set them as you go along either. You might turn off A and it was the only thing turned on. The code doesn't know that you intended to turn B on later.
    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.

  3. #3
    Forum Contributor
    Join Date
    01-09-2016
    Location
    USA,USA
    MS-Off Ver
    2016
    Posts
    1,192

    Re: Assigning pivot filter that doesn't exist breaks macro

    So how do you do skip over it in the code using countif?

    And it is erroring out even if 4/5 of the filters are available instead of just not turning on that 5th filter since it doesn't exist.

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

    Re: Assigning pivot filter that doesn't exist breaks macro

    Attach a sample workbook. Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.

+ 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. Macro to Filter Pivot Table not working when the Value does not exist
    By mtakawane in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-01-2017, 07:50 AM
  2. [SOLVED] Select Automatic Report Filter in Pivot where Filter exist in Data table else select Blank
    By vinaynaran in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-02-2016, 08:47 AM
  3. VBA Code to Skip to Next Macro if File Doesn't Exist
    By ahankerson2 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-11-2015, 01:44 AM
  4. [SOLVED] Macro Pivot Table: Most elegant way to skip a "do not display" if element doesn't exist
    By Skotzmun in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-22-2013, 05:03 AM
  5. Replies: 0
    Last Post: 03-10-2013, 04:19 PM
  6. how to stop VBA overwriting Pivot Table Value if Value doesn't exist
    By karl1985 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-27-2010, 06:47 AM
  7. Replies: 4
    Last Post: 06-18-2006, 01:10 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