Pivot Table Issues

Prevent Automatic Date Grouping in an Excel PivotTable

Aamir Naveed AkramAamir Naveed Akram Nov 25, 2026 869 views

Question details

Remove or prevent automatic grouping of dates in an Excel PivotTable, including when new years are added to the source data.

Prevent Automatic Date Grouping in an Excel PivotTable
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.
Before you start

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.

Solution 1Recommended

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.

1
Open the VBA editor

In Excel, press Alt+F11, then open the module containing your PivotTable macro or choose Insert > Module.

2
Add the ungrouping code

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

3
Remove explicit grouping

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.

4
Run and check the macro

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.

Ungroup the PivotTable date field with VBA
Grouping scope: Ungrouping a date or numeric field removes all grouping for that field. The code requires the named field and its DataRange to be available in the PivotTable.
Free Microsoft Office alternative

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.

Review and organize spreadsheet data in WPS SpreadsheetsOpen and save Microsoft Excel formats such as XLSXUse a familiar spreadsheet interface for everyday workMove compatible documents between WPS Office and Microsoft Office
microsoft office alternative - wps office

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.