Outline / group worksheet by date--are subtotals required?

fastauntie

New Member
Joined
Jan 14, 2010
Messages
2
I have a spreadsheet of several thousand rows that tracks events going back a number of years, the first column in each row beginning with a date (yes, I've confirmed they're all formatted as dates). For ease of reading, I'd like to be able to expand and collapse entries by year and maybe by month. Although there are numbers in some other columns, I have no need at all for any subtotals, and having them only clutters my view, so I actively do not want them. It seems to me that automatically outlining data by date in this way should be very simple to do, whether there's any subtotaling or not. I've tried a lot of different things, and looked at articles here & there for help, and am really stuck. Sometimes Excel insists on involving columns in the grouping as well. The most comprehensive articles tell me to start with subtotals, but I actively don't want them, and I don't understand why Excel can't just see a bunch of dates and automatically group them. What am I missing?
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
I suggest that you update your Account details (click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)

No, you do not have to have subtotals.
However, you do need to have a blank row between the 'groups'. That row is required so that when a group of rows is collapsed you can still see the "+" icon to expand that group again.
Assuming that there are currently no blank rows in column A, that the rows are sorted by date and there is a heading row, here is one way to set up grouping by year.

VBA Code:
Sub SetUpYearGroups()
  Dim r As Long
  Dim rA As Range
  
  Application.ScreenUpdating = False
  For r = Range("A" & Rows.Count).End(xlUp).Row To 3 Step -1
    If Year(Cells(r, 1).Value) <> Year(Cells(r - 1, 1).Value) Then Rows(r).Insert
  Next r
  For Each rA In Range("A2", Range("A" & Rows.Count).End(xlUp)).SpecialCells(xlConstants).Areas
    rA.Rows.Group
  Next rA
  Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,077
Messages
6,122,991
Members
449,094
Latest member
masterms

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top