Prevent Automatic Date Grouping in an Excel PivotTable
Question details
Remove or prevent automatic grouping of dates in an Excel PivotTable, including when new years are added to the source data.

- Product
- Microsoft Excel PivotTable
- Device & OS
- not provided
- Scenario
- A PivotTable uses a date field, and a VBA macro must handle data containing dates from another year.
- Observed behavior
- Excel groups dates into periods such as years, quarters, and months, and the existing macro fails when another year is added.
Check the worksheet name, PivotTable name, and date field name before editing the macro. Also check whether the existing code calls AutoGroup, which explicitly groups the field.
Ungroup the PivotTable date field with VBA
Use this method to remove date grouping as part of a macro after the PivotTable is created or refreshed.
In Excel, press Alt+F11, then open the module containing your PivotTable macro or choose Insert > Module.
Add the following code after the PivotTable is created or refreshed, replacing the worksheet, PivotTable, and field names as needed: Sub UngroupPivotDates() Dim PvtTbl As PivotTable Dim rngGroup As Range Set PvtTbl = Worksheets("Sheet6").PivotTables("PivotTable1") Set rngGroup = PvtTbl.PivotFields("Dates").DataRange rngGroup.Cells(1).Ungroup End Sub
In the same VBA editor, find any AutoGroup or Group call for the date field. Remove it if the dates should remain ungrouped, and run the ungrouping code after any refresh or grouping operation that can reintroduce grouping.
Run the macro from the VBA editor or Excel's Developer > Macros menu, then check the PivotTable to confirm the date items are no longer grouped.

Disable automatic date grouping in Excel settings
Use this setting, where available, to stop Excel from automatically grouping date fields in PivotTables.
Ungroup dates manually in the PivotTable
Use this option for a quick, one-time removal without editing VBA.
Work with spreadsheet data in WPS Office
WPS Office is a free, lightweight alternative with a familiar interface and support for Microsoft Office formats, making it easy to move everyday spreadsheet work from Excel. It does not change Excel's PivotTable grouping settings or fix Excel VBA macros.

Frequently Asked Questions
How do I ungroup dates in an Excel PivotTable without VBA?
Right-click a grouped date item in the PivotTable and select Ungroup. This removes all grouping for that date field.
Can I stop Excel from grouping dates automatically?
In supported Excel for Windows versions, go to File > Options > Data and select Disable automatic grouping of Date/Time columns in PivotTables. Ungroup existing fields separately.
Why do dates still group after I change the Excel setting?
The setting does not override explicit VBA commands. Check your macro for AutoGroup or Group calls and remove them if grouping is not wanted.
Where should I put the VBA ungrouping code?
Place it after the PivotTable is created or refreshed, and after any operation that may group the date field. Make sure the worksheet, PivotTable, and field names match your workbook.




