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
 

Some videos you may like

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN

SydneyGeek

MrExcel MVP
Joined
Aug 5, 2003
Messages
12,251
Are the groups subtotals? A bit more info would be useful, along with a chunk of the worksheet (use Colo's HTML Maker)

Denis
 

SydneyGeek

MrExcel MVP
Joined
Aug 5, 2003
Messages
12,251

ADVERTISEMENT

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
 

SydneyGeek

MrExcel MVP
Joined
Aug 5, 2003
Messages
12,251

ADVERTISEMENT

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
 

rockatubc

New Member
Joined
Jan 28, 2005
Messages
19
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.
 

Watch MrExcel Video

Forum statistics

Threads
1,122,576
Messages
5,596,981
Members
414,115
Latest member
SFUser

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
Top