+ Reply to Thread
Results 1 to 7 of 7

Filter Pivot table based on Range

  1. #1
    Registered User
    Join Date
    06-12-2012
    Location
    columbus, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    7

    Filter Pivot table based on Range

    Hi, I have been trying to figure this one out for a while and am at my wit's end. I came across another post on this forum that does almost what I am looking for (that code is below); the only difference is, I need the Range "B3" to be multiple cells; the cells I need to call from will always be A2:A11, or I could put it into a named range. Can someone help me to edit this code so it will do multiple cells? Thank You!

    Please Login or Register  to view this content.
    p.s. to give credit where credit is due the above code came from a forum user by the name "T-J"

  2. #2
    Registered User
    Join Date
    05-19-2011
    Location
    San Diego, CA
    MS-Off Ver
    Excel 2010
    Posts
    33

    Re: Filter Pivot table based on Range

    The function Filter_PivotField below does what you describe.
    The examples show how to call it with a Range Address reference or Named Range.


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

  3. #3
    Registered User
    Join Date
    06-12-2012
    Location
    columbus, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Filter Pivot table based on Range

    Hi and thanks again for your help!
    I am getting an error, "Wrong number of arguments or invalid property assignment". Here is what I have done with your code:
    1. I copied the public function (Filter_PivotField) and inserted a new module in my workbook, then pasted the code in there. I did not tweak any of that code.
    2. I then created a new macro, "Temp 1" and pasted in and tweaked the below code:

    Please Login or Register  to view this content.
    "UOM Data" is the sheet which contains the Pivot Table.
    "Dept Lines" is the sheet which contains the range I want to reference (A2:A11)
    "Dept Name Dept Number" is the name of the field I am trying to filter in the pivot table.

    Does anything right away pop out that I have done wrong?

    Thanks!

  4. #4
    Registered User
    Join Date
    05-19-2011
    Location
    San Diego, CA
    MS-Off Ver
    Excel 2010
    Posts
    33

    Re: Filter Pivot table based on Range

    Try replacing this line of code in the Function Filter_PivotField

    Please Login or Register  to view this content.
    If that doesn't fix it, please attach a copy of your workbook with any sensitive data removed.
    (It's very nice that ExcelForum supports file attachments!)

  5. #5
    Registered User
    Join Date
    06-12-2012
    Location
    columbus, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Filter Pivot table based on Range

    JS411, Thank you very much! It worked perfectly once I made that change!

    Also, for anyone who may come across this forum searching for answers to this type of problem, I also got this code to work correctly (However, this only works for a static range, what JS411 provided above can be dynamic:

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    02-28-2016
    Location
    Crete
    MS-Off Ver
    10
    Posts
    3

    Re: Filter Pivot table based on Range

    Hi to All

    Could someone give me specific instructions about the how to use the codes above?

    I have copied the Public Function to a separate module in my work book.
    In another module i have the Sub Example2()


    Is there any specific name i must use for the sub example2()???

    i get this error:

    Compile error:

    Wrong number of arguments or invalid property assignment

    Notes*
    I have replaced the

    Please Login or Register  to view this content.
    Thank you in advance

  7. #7
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,938

    Re: Filter Pivot table based on Range

    Quote Originally Posted by excelakos View Post
    Hi to All

    Could someone give me specific instructions about the how to use the codes above?

    I have copied the Public Function to a separate module in my work book.
    In another module i have the Sub Example2()


    Is there any specific name i must use for the sub example2()???

    i get this error:

    Compile error:

    Wrong number of arguments or invalid property assignment

    Notes*
    I have replaced the

    Please Login or Register  to view this content.
    Thank you in advance
    Administrative Note:

    Welcome to the forum.

    We are happy to help, however whilst you feel your request is similar to this thread, experience has shown that things soon get confusing when answers refer to particular cells/ranges/sheets which are unique to your post and not relevant to the original.

    Please see Forum Rule #4 about hijacking and start a new thread for your query.

    If you are not familiar with how to start a new thread see the FAQ: How to start a new thread
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

+ 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