Hi All
I am hoping someone can help
I'm trying to group a pivot table by year & month in my workbook, but getting the following error: 'Runtime error 1004 - Group method of range class failed'
I tried to follow the same principle as this MrExcel video, as I don't want to have to select or reference a specific cell in the code (in case the user inadvertently changes the pivot address by adding/deleting rows/columns)
But I can't seem to make it work.
Any help appreciated
Vicky
Example workbook
Group Pivot By Date.xlsm
Also asked here VBA: Group Pivot Dates By Year
I am hoping someone can help
I'm trying to group a pivot table by year & month in my workbook, but getting the following error: 'Runtime error 1004 - Group method of range class failed'
I tried to follow the same principle as this MrExcel video, as I don't want to have to select or reference a specific cell in the code (in case the user inadvertently changes the pivot address by adding/deleting rows/columns)
But I can't seem to make it work.
Any help appreciated
Vicky
VBA Code:
Sub GroupPivotDate()
Dim pf As PivotField
Set pf = ActiveSheet.PivotTables("PivotTable1").PivotFields("Sale Date")
pf.LabelRange.Group Start:=True, End:=True, Periods:=Array(False, False, False, _
False, True, False, True)
End Sub
Example workbook
Group Pivot By Date.xlsm
Also asked here VBA: Group Pivot Dates By Year
Last edited by a moderator: