(Solved) – VBA Add column as Pivot filter


I’m trying to create a code that adds a whole column from user input data (all column A except A1) to a pivot located in another sheet

So far, I’ve been able to make it to clear the current filters, but I have no idea on how to add the filter.

This is what I have so far:

-> Agent Staffing is where the Pivot is located
-> PivotT is the name of the table

    Dim ws As Worksheet
    Dim wsp As Worksheet
    Set ws = ActiveSheet
    Set wsp = ThisWorkbook.Worksheets("Agent staffing") 
    With wsp.PivotTables("PivotT").PivotFields("Login")
        .PivotFilters.Add Type:=xlCaptionEquals, Value1:=ws.Columns("A")

    End With
End Sub

Any help there? I’m starting on VBA so there is a lot I’m no aware of yet.


Leave a Reply

Your email address will not be published. Required fields are marked *