I'm brand new to vba. I was able to create a pivot table without too much hassle, but I'm struggling with flitering a pivot field with a formula.

I need to show all pivot items that match the below:
1. Any blank dates (fields) that do not have "Certificate" in the name
2. Any expired dates
3. Any dates that fall between 2 specific dates (these dates are determined by adding/subtracting 2 months from the expiration date)

I can create the formula in an excel spreadsheet but am struggling with getting it to work in VBA.
=IF(AND(G2="",ISERROR(FIND("Certificate",I2))=TRUE),"Yes",IF(AND(G2<>"",G2<TODAY()),"Yes",IF(AND(G2>=(DATE(YEAR(TODAY()),MONTH(TODAY())-2,DAY(TODAY()))),G2<=(DATE(YEAR(TODAY()),MONTH(TODAY())+2,DAY(TODAY())))),"Yes","")))
G2 = Expiration Date
I2 = Certification Name

Here is what I tried to do:

Dim pi as PivotItem

With ActiveSheet.PivotTables("PivotTable1").PivotFields("Expiration Date")
    For Each pi In .PivotItems
    If pi.Name Is Null And pi.Name Like "Certificate*" Then
    pi.Visible = True
    ElseIf pi.Name Is Not Null And pi.Name < Date Then
    pi.Visible = True
    ElseIf pi.Name >= DateAdd("m", -2, Date) And pi.Name <= DateAdd("m", 2, Date) Then
    Else
    pi.Visible = False
    End If
    Next pi
End With
The "pi.Name" keeps giving me a Type Mismatch error.

Let me know if you need my entire code. Any help is appreciated. Thanks!!!