Grouping Question

rockatubc

New Member
Joined
Jan 28, 2005
Messages
19
Hi,

How can I sum a column up that changes according to what I group and what I do not group?

Thanks
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Are the groups subtotals? A bit more info would be useful, along with a chunk of the worksheet (use Colo's HTML Maker)

Denis
 
Upvote 0
How are you grouping the data? Do you have another cell where the "groups" are entered? And will you be grouping by more than one item at a time?

Denis
 
Upvote 0
I thought SUBTOTAL would help, but it only omits FILTERED rows, not grouped rows that have been hidden. This looks like a job for Aladin, or one of the other formula gurus...

However, here's a custom function that does the job.
Code:
Function SUBTOTAL_VIS(Target)
   Dim X As Double
   Dim c As Range
   Application.Volatile
   X = 0
   For Each c In Target
      If c.RowHeight = 0 Then
         X = X
      Else
         X = X + c.Value
      End If
   Next c
   SUBTOTAL_VIS = X
End Function
Paste this code into a new module.
Enter the formula using the function wizard (Fx) and selecting User Defined Functions. Target is the range that you want to sum.

To exclude grouped values from the total, use the outline buttons to collapse the outline.

Note: this code will need to be placed in the workbook where you want to use it. You'll also need to recalc the sheet (Shift + F9) when you change the outline.

Denis
 
Upvote 0
Ahh.stupid question but i was wondering how to actually paste this code into a new module?? What is a module??

How do I enter the formula using the function wizard (Fx) and selecting User Defined Functions?? Do I have to add this fuction to the user defined function group??

Thank you very much.
 
Upvote 0

Forum statistics

Threads
1,213,552
Messages
6,114,278
Members
448,559
Latest member
MrPJ_Harper

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