subtotal() function doing Data-->subtotal job

lezawang

Well-known Member
Joined
Mar 27, 2016
Messages
1,805
Office Version
  1. 2016
Platform
  1. Windows
Hi
I have a table like the one below. I sorted "Store" column. I want to find the subtotal of east store or subtotal of north store or north store etc. using subtotal() function.

I know after sorting, I can go to Data tab-->subtotal, that is an option
another option maybe I can use SumIf() function. Another option I can use pivot table.

But I wonder, can I use subtotal() function to do exactly what Data-->Subtotal does? Thank you very much.

[TABLE="width: 256"]
<colgroup><col width="64" span="4" style="width:48pt"> </colgroup><tbody>[TR]
[TD="width: 64"]name[/TD]
[TD="width: 64"]store[/TD]
[TD="width: 64"]item[/TD]
[TD="width: 64"]price[/TD]
[/TR]
[TR]
[TD]linda[/TD]
[TD]east[/TD]
[TD]tv[/TD]
[TD="align: right"]662[/TD]
[/TR]
[TR]
[TD]jack[/TD]
[TD]east[/TD]
[TD]dryer[/TD]
[TD="align: right"]444[/TD]
[/TR]
[TR]
[TD]alex[/TD]
[TD]east[/TD]
[TD]computer[/TD]
[TD="align: right"]723[/TD]
[/TR]
[TR]
[TD]allen[/TD]
[TD]east[/TD]
[TD]tv[/TD]
[TD="align: right"]356[/TD]
[/TR]
[TR]
[TD]mary[/TD]
[TD]east[/TD]
[TD]dryer[/TD]
[TD="align: right"]792[/TD]
[/TR]
[TR]
[TD]sam[/TD]
[TD]north[/TD]
[TD]washer[/TD]
[TD="align: right"]452[/TD]
[/TR]
[TR]
[TD]adam[/TD]
[TD]north[/TD]
[TD]tv[/TD]
[TD="align: right"]998[/TD]
[/TR]
[TR]
[TD]david[/TD]
[TD]north[/TD]
[TD]dryer[/TD]
[TD="align: right"]307[/TD]
[/TR]
[TR]
[TD]eric[/TD]
[TD]north[/TD]
[TD]computer[/TD]
[TD="align: right"]464[/TD]
[/TR]
[TR]
[TD]jim[/TD]
[TD]south[/TD]
[TD]dryer[/TD]
[TD="align: right"]410[/TD]
[/TR]
[TR]
[TD]tim[/TD]
[TD]south[/TD]
[TD]computer[/TD]
[TD="align: right"]890[/TD]
[/TR]
[TR]
[TD]tom[/TD]
[TD]south[/TD]
[TD]washer[/TD]
[TD="align: right"]899[/TD]
[/TR]
[TR]
[TD]sue[/TD]
[TD]south[/TD]
[TD]tv[/TD]
[TD="align: right"]931[/TD]
[/TR]
[TR]
[TD]liz[/TD]
[TD]south[/TD]
[TD]dryer[/TD]
[TD="align: right"]739[/TD]
[/TR]
[TR]
[TD]dana[/TD]
[TD]west[/TD]
[TD]computer[/TD]
[TD="align: right"]459[/TD]
[/TR]
[TR]
[TD]anna[/TD]
[TD]west[/TD]
[TD]tv[/TD]
[TD="align: right"]967[/TD]
[/TR]
[TR]
[TD]kim[/TD]
[TD]west[/TD]
[TD]dryer[/TD]
[TD="align: right"]931[/TD]
[/TR]
[TR]
[TD]louis[/TD]
[TD]west[/TD]
[TD]computer[/TD]
[TD="align: right"]481[/TD]
[/TR]
[TR]
[TD]jeff[/TD]
[TD]west[/TD]
[TD]washer[/TD]
[TD="align: right"]737[/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
I don't think you can easily use SUBTOTAL() to find, for example, the subtotal for SOUTH, unless you are using Data Filters to select SOUTH entries.

I think in this situation I would use SUMIF (or SUMIFS), or PIVOT TABLE.
 
Upvote 0
You can use subtotal() as a complement to sumproduct, that way it also helps you when you have a filter, eg by item: computer, and you want to get the subtotal of "west", tyr this:

Excel Workbook
ABCDEFG
1namestoreitemprice940
4alexeastcomputer723
10ericnorthcomputer464
12timsouthcomputer890
16danawestcomputer459
19louiswestcomputer481
Hoja3
 
Upvote 0

Forum statistics

Threads
1,223,243
Messages
6,170,971
Members
452,371
Latest member
Frana

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