'VBA PivotTable problem with grouping issue

I have a PivotTable that shows dates in a row label, but from the data it always takes more than one date needs. I would like to add a function to the macro that would group me this label to the annual range.

But when I try to do it with this function it shows me that getting the PivotTables property is not possible. I dont know how to is good solution for this

tbName1 = "Tabela przestawna8"
y.Sheets("analityka_ID").PivotTables(tbName1).PivotFields(ActiveSheet.PivotTables(tbName1).PivotFields.Count - 1).Orientation = 0

What i Have is below bu i need here range 2020M10 - 2021M10

enter image description here



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source