If your summary data is created using the GROUPBY formula (or any other dynamic array formula like GROUPBY, PIVOTBY, or SUMMARIZE — which are available in newer versions of Excel like Excel 365), and you're trying to implement a "drill-down" behavior when double-clicking a summary row, there's a key challenge:
💡 The original detail rows are not directly linked to each group in the GROUPBY output, so Excel doesn't know what underlying data corresponds to each summary.
🔍 Understanding the Problem
Let’s say you have something like this:
Category
Total Sales
A
$10,000
B
$15,000
This table was generated using:
excel
=GROUPBY(CategoryRange, SalesRange, SUM)
Now you want to double-click on a row like "Category A" and see all the underlying sales records that contributed to $10,000.
But since GROUPBY is a formula-based summary (not grouped rows or pivot tables), there's no built-in link between the summary and the details.
So we need to simulate that link ourselves via custom VBA code + logic.
✅ Solution: Use VBA + Helper Logic to Map Summary Rows to Details
You can make it work by doing the following:
🧩 Step 1: Add an Identifier for Each Group in the GROUPBY Output
Assume your raw data looks like this:
Category
Sales
A
2000
A
3000
B
5000
A
5000
B
10000
Then your GROUPBY result might be:
Category
Total Sales
A
10000
B
15000
Now, insert a hidden column with the grouped category name (just repeat the category). So your GROUPBY becomes:
🧩 Step 2: Write VBA to Handle Double-Click and Filter Raw Data Based on Group ID
Here’s how the VBA will work:
On double-click of a summary row → get the HiddenGroupID value.
Filter the original raw data where Category = HiddenGroupID.
Display filtered data in a new sheet or below the summary.
✅ VBA Code Example
vba
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Dim wsSummary As Worksheet, wsRaw As Worksheet, newWs As Worksheet
Dim groupID As String, filterRange As Range
Set wsSummary = Me
Set wsRaw = ThisWorkbook.Sheets("RawData") ' Change to your raw data sheet name
' Check if clicked within the summary table
If Not Intersect(Target, wsSummary.Range("A2:A100")) Is Nothing Then
Cancel = True
' Assume group ID is in column C (hidden)
groupID = wsSummary.Cells(Target.Row, 3).Value
' Create new sheet
Set newWs = ThisWorkbook.Worksheets.Add
newWs.Name = "DrillDown_" & groupID
' Copy headers (assumes raw data has headers in row 1)
wsRaw.Rows(1).Copy newWs.Rows(1)
' Apply filter and copy visible data
With wsRaw.Range("A1:B1000") ' Adjust range to match your raw data
.AutoFilter Field:=1, Criteria1:=groupID
.Offset(1).SpecialCells(xlCellTypeVisible).Copy newWs.Rows(2)
.AutoFilterMode = False
End With
newWs.Columns.AutoFit
newWs.Activate
End If
End Sub
📌 Summary
Step
Action
1
Modify your GROUPBY output to include a hidden column with the grouping key.
2
Store your raw data on a separate worksheet.
3
Use VBA to capture double-clicks on the summary rows and extract matching raw data.
4
Show the filtered raw data in a new sheet — mimicking drill-down behavior.
🔁 How to Get Back to Original View?
Since this approach creates a new sheet with filtered raw data, users can simply switch back to the summary sheet manually. There’s no automatic “back” button, but you can optionally add a button or shortcut to return.
Alternatively, you could show/hide detail rows below the summary instead of opening a new sheet — let me know if you'd prefer that version too.
Would you like a downloadable sample file or help adapting this to your exact layout?