Filter dynamic in pivot table

Hello everyone, colleagues I need your great help with this case, I have been doing an automation of a process where a management report is generated, everything is done in excel and I have managed to do it through excel activities and most of all by invoking VBA, but I have reached a knot and I don’t know how to solve it.
In a part of the report, a pivot table is generated, which I have managed to update and filter (the current month is filtered and the same month but last year, that is, 2021-06 and 2020-06) that I did through this code
Function SelectFilter (currentMonth, previousMonth)

Worksheets ("Total Company"). PivotTables ("PivotTable1"). PivotFields ("Calendar Year / Month"). _
    CurrentPage = "(All)"
With Worksheets ("Total Company"). PivotTables ("PivotTable1"). PivotFields ("Calendar Year / Month")
    .PivotItems (currentMonth) .Visible = True
    .PivotItems (previousMonth) .Visible = True
End With

End Function

But now I am updating another pivot table but this shows what has accumulated throughout the year compared to what was carried last year, that is, it is filtered (2021-01,2021-02,2021-03,2021-04 , 2021-05,2021-6,2020-01,2020-02,2020-03,2020-04,2020-05,2020-06) obviously the amount of filtered data will change as the months progress, how can I do this?

I have searched a lot in excel forums but I have not been able to understand much of VBA