Click here to Skip to main content
15,881,803 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

I am hoping that someone may be able to help with the following.

I currently have a pivot table that has 2 filters. What I need to be able to do is to link these 2 filters to say their own named range that will hold the filter values, and there lies my problem.

I currently have an exxcel 2007 pivot table that I can automatically update the filter but I am at a loss how to do this for 2 filters and for multiple items?? If it is of any use my current script to filter on just 1 item is below;


Code:
Private Sub Worksheet_Change(ByVal Target As Range)
  
   If Not Target.Address = Range("SelectDate").Address Then Exit Sub
    
   Dim PT As PivotTable
   Dim ptItem As PivotItem
    
   On Error Resume Next
  
    For Each PT In Worksheets("8c. Pivot").PivotTables
        With PT.PivotFields("Period (01/MM/YYYY)")
            If .EnableMultiplePageItems = True Then
               .ClearAllFilters
            End If
       
            Set ptItem = .PivotItems(Target.Value)
            If Not ptItem Is Nothing Then
               .CurrentPage = Target.Value
            End If
        
        End With
    
    Next
End Sub


If anyone has any ideas or can help it would be massively appreciated,

Cheers
Posted
Comments
ZurdoDev 7-Jan-15 11:04am    
Is it something you can do by recording a macro? Or even closely do? If so, you can see the code that you'll need to work with.
Member 11359020 7-Jan-15 11:07am    
Hi Ryan,

Unfortunatly not. The User makes a selection from a pop up form. The selections that the user makes then needs to refresh the pivot table.

I can change 1 pivot table filter selection with vb easy enough but can not make it work for multiple cell references?
ZurdoDev 7-Jan-15 11:13am    
If you can do it with 1 filter then you likely can examine the code and see how to do it using multiple cells.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900