+ Reply to Thread
Results 1 to 3 of 3

Using a macro to filter text data with a wildcard in a pivot table erroring out

  1. #1
    Registered User
    Join Date
    07-29-2019
    Location
    Philadelphia, PA
    MS-Off Ver
    Office 2016
    Posts
    2

    Using a macro to filter text data with a wildcard in a pivot table erroring out

    I'm trying to use a wildcard to sort the data.

    Capture - Copy.JPG

    Trying to sort this data by the first column to get a report showing all the ABC items along with any N/A items and any blank items.

    When trying a macro that has this in it:

    Please Login or Register  to view this content.
    I get an error:

    Run-time error '1004':
    AutoFilter method of Range class failed

    When trying to use:

    Please Login or Register  to view this content.
    I get an error:

    Run-time error '1004':
    Unable to get the PivotItems property of the PivitField class

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: Using a macro to filter text data with a wildcard in a pivot table erroring out

    Hi Billy,

    I don't completely understand your problem but it sounds like you need to discover the Slicer tool for your pivot table. If that doesn't work then how about doing an Advanced Filter using wildcard criteria and then do the pivot on the filtered table? Perhaps the VBA after using the above would work for you?
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Registered User
    Join Date
    07-29-2019
    Location
    Philadelphia, PA
    MS-Off Ver
    Office 2016
    Posts
    2

    Re: Using a macro to filter text data with a wildcard in a pivot table erroring out

    I'll admit I'm not familiar with slicers so I will check that out.

    Here's more detail on the problem and what I am attempting to accomplish. What I have is a report that I get which needs to be sorted, filtered, formatted, and then emailed out to different groups showing the employees they are responsible for. The first 3 letters define an overall department group. So "ABC-*" is one group, "DEF-*" is another group, etc. The report needs to be broken out to all "ABC-*", "N/A", and "Blanks" and saved off for emailing. Then it needs to be broken out for all "DEF-*", "N/A", and "Blanks", saved off, and so on continuing down the list. There's a few more 3 letter prefix designations which aren't showing on the screenshot that will need filtering along with the "N/A' and "blanks". All said it ends up being 5 or 6 different reports that get broken out and mailed off.

    Since this needs to be done on a regular basis I am looking to run a macro to handle the repetitive tasks.

    The Dept is dynamic. Today there may be 3 "ABC-*" departments listed. Tomorrow there may be 2 more added, the day after that there may be 3 removed. It's fluid. If it was static I could just define each possible option and just have the macro make it visible or not using the full text. However, since the text after "ABC-*" could change daily, I thought I would need a wildcard to identify it and make anything with "ABC-* visible and make anything with a "DEF-*" not visible, save it off, then make everything with "ABC-*" not visible, make everything with "DEF-*" visible, save it, and so on for each Department group on the report.

    Filtering with Wildcards seems to be giving me issues when using it on the pivot table above. I've got it working correctly on other reports I run with Pivot tables. I'm guessing having that Sum of Hours Entered in Row 1 is throwing things off because that is the only difference I've found in the 2 options. I'll check the Advanced Filtering and Slicer to see if that can give me what I need. Ideally I'm looking to automate this as much as possible. Honestly, This part of the macro is just to stop me from having to go in, uncheck all, and recheck off what I want to report on for all the different Department Groups. It's a few minutes each day, but it seems like something that's perfect for automation since it is a repetitive task.

+ 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. Inserting filter into pivot table via macro errors if filter doesn't exist.
    By taylorsm in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-03-2018, 10:24 AM
  2. Replies: 9
    Last Post: 09-05-2017, 06:14 PM
  3. Pivot table filter not changing data in table - Using macro
    By DJDRU in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 11-09-2016, 06:16 AM
  4. Replies: 1
    Last Post: 09-06-2016, 04:59 AM
  5. Replies: 1
    Last Post: 12-12-2014, 06:46 AM
  6. Replies: 0
    Last Post: 11-12-2014, 01:16 AM
  7. Macro Help Needed - Link Pivot Table Filter to Regular Table AutoFilter
    By ycx1129 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-11-2011, 12:54 PM

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