• Skip to main content
  • Skip to header right navigation
  • Skip to site footer

My Online Training Hub

Learn Dashboards, Excel, Power BI, Power Query, Power Pivot

  • Courses
  • Pricing
    • Free Courses
    • Power BI Course
    • Excel Power Query Course
    • Power Pivot and DAX Course
    • Excel Dashboard Course
    • Excel PivotTable Course – Quick Start
    • Advanced Excel Formulas Course
    • Excel Expert Advanced Excel Training
    • Excel Tables Course
    • Excel, Word, Outlook
    • Financial Modelling Course
    • Excel PivotTable Course
    • Excel for Customer Service Professionals
    • Excel for Operations Management Course
    • Excel for Decision Making Under Uncertainty Course
    • Excel for Finance Course
    • Excel Analysis ToolPak Course
    • Multi-User Pricing
  • Resources
    • Free Downloads
    • Excel Functions Explained
    • Excel Formulas
    • Excel Add-ins
    • IF Function
      • Excel IF Statement Explained
      • Excel IF AND OR Functions
      • IF Formula Builder
    • Time & Dates in Excel
      • Excel Date & Time
      • Calculating Time in Excel
      • Excel Time Calculation Tricks
      • Excel Date and Time Formatting
    • Excel Keyboard Shortcuts
    • Excel Custom Number Format Guide
    • Pivot Tables Guide
    • VLOOKUP Guide
    • ALT Codes
    • Excel VBA & Macros
    • Excel User Forms
    • VBA String Functions
  • Members
    • Login
    • Password Reset
  • Blog
  • Excel Webinars
  • Excel Forum
    • Register as Forum Member

Excel SUBTOTAL Formula Explained

You are here: Home / Excel Formulas / Excel SUBTOTAL Formula Explained
October 6, 2010 by Mynda Treacy

If you think SUM is handy, wait til you meet SUBTOTAL.  SUBTOTAL has so many tricks up its sleeve you’ll be mesmerised, but don’t be put off because this formula is simple.

If you’ve ever worked with hidden rows you’ve probably wanted to find the total of a column excluding what’s hidden. What about finding out the AVERAGE, COUNT, MAX, or MIN excluding the hidden or filtered rows?  SUBTOTAL can do all this and more, and it’s one of the easiest formulas to get your head around.

Excel SUBTOTAL Formula

The syntax of the SUBTOTAL function in Excel is:

=SUBTOTAL(function_num,ref1,...)

Don’t be put off by the ever helpful syntax.  I said this formula was and you’ll see as I translate it into English:

=SUBTOTAL(what type of total do you want, what range/s do you want to subtotal)

function_num is referring to the type of total you want.  You see, SUBTOTAL can be used to SUM, COUNT, AVERAGE and much more.  See the table below for a complete list of the different types of totals you can use SUBTOTAL for.  You simply enter the function_num from the table below into your formula to instruct Excel what type of total you want.

Excel SUBTOTAL function arguments

For example if we wanted to SUM a column of data containing hidden rows (say our range is C4:C32) our formula would read:

=SUBTOTAL(9,C4:C32)

This would give us the total for all values in the range C4:C32 including those on hidden rows. i.e. those rows hidden using right-click row > Hide.

Note: Formatting your data in an Excel Table and applying filters results in the function numbers 9 to 11 ignoring hidden or filtered rows. It appears to be a bug and therefore, you should avoid using Tables if you want to include hidden values in your results.

Now you see how easy it is, let’s go over some of the features of SUBTOTAL:

1)      In the table above you will notice there are two columns.  The first column containing function numbers 1-11 will exclude any cells that are hidden by a filter

2)      The second column containing function numbers 101-111 do the same as above, but will also exclude any cells in rows that have been manually hidden.

3)      You can use SUBTOTAL on more than one range. e.g. =SUBTOTAL(9,C4:C32,D4:D32,E5:E7 etc.etc)  Simply separate any non-contiguous ranges by a comma.

4)      SUBTOTAL ignores any other subtotals in the range.  Taking the example below, our Grand Total on row 37 will not include the Night Garden Total, Spider Man Total, or the Wiggles Total even though the range for the Grand Total formula is C21:C36.

Excel SUBTOTAL Formula results

Tips and Ideas for SUBTOTAL

  • You can automatically insert SUBTOTAL’s (as I did above) using the SUBTOTAL tool on the ‘Insert’ tab of the ribbon.  You’ll find a detailed video tutorial in our Premium training program on how to insert a SUBTOTAL automatically.
  • Why not put the SUBTOTAL formulas at the top of your data.  This is handy if your data goes on for thousands of rows and you don’t want to be scrolling to the bottom to see the totals all the time.
  • Set your SUBTOTAL formula up to dynamically update for any new rows added to the bottom of your data by using the OFFSET function nested in your SUBTOTAL, or link the SUBTOTAL formula to an Excel Table.

Don’t forget you can get more free Excel training and video tutorials from My Online Training Hub. Sign up here for instant access to our free online training.

Please share the knowledge with your friends and colleagues on Twitter, LinkedIn and facebook etc.

Got a clever way you use SUBTOTAL?  Let us know by leaving a comment.

More Excel Formulas Posts

ai-aided excel formula editor

AI Aided Excel Formula Editor

Save time with this free AI Excel formula editor add-in that writes, edits, improves and interprets formulas for you!
top excel functions for data analysts

Top Excel Functions for Data Analysts

Must know Excel Functions for Data Analysts and what functions you don’t have to waste time learning and why.
excel advanced formula environment

Excel Advanced Formula Environment

Excel Advanced Formula Environment is a long awaited, new improved way to write, name and store Excel formulas.
Pro Excel Formula Writing Tips

Pro Excel Formula Writing Tips

Must know Excel formula writing tips, tricks and tools to make you an Excel formula ninja, including a new formula editor.
excel shaping arrays

New Array Shaping Excel Functions

The Excel Shaping Array Functions makes it easier than ever to reshape arrays and ranges using these purpose built functions
excel nested if functions what not to do

Excel IF Formulas and What Not To Do

Excel IF formulas can get out of hand when you nest too many IFs. Not only do they become unwieldy they’re difficult for anyone to understand
excel image function

Excel IMAGE Function

The Excel IMAGE Function enables you to embed images in a cell using a formula. It supports BMP, JPG/JPEG, GIF, TIFF, PNG, ICO, and WEBP files

Excel VSTACK and HSTACK Functions

New Excel VSTACK and HSTACK functions makes combining arrays of cells easy and with some clever tricks we can extend their capabilities.
identify overlapping dates and times in excel

Identify overlapping dates and times in Excel

How to identify overlapping dates and times in Excel with a formula that checks a range of cells. Works with Dates and Times.
New Excel Text Functions

TEXTSPLIT, TEXTBEFORE and TEXTAFTER Functions

TEXTAFTER, TEXTBEFORE and TEXTSPLIT are exciting new Excel Text functions. They’re fairly self-explanatory, however TEXTSPLIT has some cool features.


Category: Excel Formulas
Previous Post:if or and if and formulasExcel IF AND OR Functions Explained
Next Post:Get Your Own Interactive Google Map FREE

Reader Interactions

Comments

  1. Gary Allen

    June 9, 2021 at 2:44 am

    When I’m entering a formula, is there a way to view the valid function numbers dynamically?

    Reply
    • Catalin Bombea

      June 9, 2021 at 12:38 pm

      Yes,
      Select the reference and press the F9 key.

      Reply
  2. Heather Swangler

    July 29, 2017 at 5:49 am

    How do I subtotal multiple sheets in a file? I would like to subtotal using the same format for each tab and I would like to complete at once. I think I can create a macro and leave the sheet name the same for all tabs and run a macro for each sheet. But I would rather subtotal multiple sheets at once. Is there a way to do this or do I need a VBA macro to complete?

    Thanks for your help!

    Reply
    • Mynda Treacy

      July 29, 2017 at 9:40 am

      Hi Heather,

      Do you mean like this: https://www.myonlinetraininghub.com/how-to-insert-subtotals-in-excel

      Mynda

      Reply
  3. Ken Kennedy

    March 29, 2017 at 2:20 am

    =SUBTOTAL(9,E1:E132) What does the “9” mean in this formula?

    Reply
    • Catalin Bombea

      March 29, 2017 at 5:06 am

      Hi Ken,
      9 represents the SUM function, for all the cells from the indicated range. There is another version of the SUM function in SUBTOTAL:
      Subtotal(109,E1:E132). 109 repesents a SUM of the fisible cells only, from the indicated range.

      Reply
  4. sushil

    May 23, 2016 at 3:14 pm

    excellent tips

    Reply
    • Mynda Treacy

      May 23, 2016 at 3:35 pm

      Thanks, Sushil. Glad you found them useful.

      Mynda

      Reply
  5. Phina Deal

    February 25, 2016 at 6:51 am

    Thank you so much Mynda, this is awesome!

    Reply
    • Mynda Treacy

      February 25, 2016 at 11:02 am

      You’re welcome, Phina. Glad you liked it 🙂

      Reply
  6. Anne

    January 5, 2016 at 10:39 am

    Manythanks Myanda.Easy to follow and understand and very clear

    Reply
    • Mynda Treacy

      January 5, 2016 at 10:42 am

      My pleasure, Anne. Glad I could help 🙂

      Reply
  7. Sanjay Bhat

    May 17, 2015 at 6:12 am

    Thank you for making very nice, easy to understand videos in Premium training on subtotals.

    Reply
    • Mynda Treacy

      May 17, 2015 at 7:44 am

      Thanks, Sanjay. Glad you’ve found them useful 🙂

      Reply
  8. lalit

    October 10, 2014 at 11:59 am

    Realy i like it way which you describe the all formula’s.excellent

    Reply
    • Philip Treacy

      October 10, 2014 at 12:40 pm

      Thanks Lalit

      Reply
  9. amarnath ray

    August 1, 2014 at 1:54 am

    Wondeful!!!

    Reply
    • Mynda Treacy

      August 1, 2014 at 9:14 am

      Thanks, Amarnath 🙂

      Reply
  10. Orlando

    November 7, 2013 at 5:01 am

    Hello Mynda,
    When I try to apply the Subtotal formula: =SUBTOTAL(9,SUBTOTAL[Viewers]), in the spreadsheet you provide in this tutorial, it gives me an #REF, no result. What does it mean, why is it giving me that message, what am I doing wrong?

    Reply
    • Mynda Treacy

      November 7, 2013 at 9:42 am

      Hi Orlando,

      It seems Excel did not like the fact that there was a named range that is the same as a Function. i.e. Subtotal. It’s odd that it didn’t throw an error originally. I’ve made a change now so that the table is called SUBTOTAL_tbl.

      Please download the Excel file again here.

      Note: this is a .xlsx file please ensure your browser doesn’t change the file extension on download.

      Kind regards,

      Mynda.

      Reply
  11. R VENKATARAMAN

    June 20, 2013 at 2:38 pm

    is not “subtotal” takes into account only VISIBLE rows. then why thos 101 to 109

    Reply
    • Carlo Estopia

      June 20, 2013 at 5:43 pm

      Hi R Venkataraman,

      Thanks for dropping by.

      I don’t understand actually what question you’re trying to raise here?
      Are you asking why function_nums 101 to 109 is redundant because you premised
      that “subtotals” are only for visible rows; hence, there’s no need to state that 101 to 109
      are for visible rows only?

      Well, I think this is what this post is all about that there are two types of function_nums:
      those that disregards visibility of data:1 to 11 and those that considers only visible data: 101 to 111.

      So, there it is. There is such thing as subtotaling everything regardless of visibility ; that is, using
      function_nums: 1 to 11. Therefore,stating that 101 to 111 function_nums are for visible data only is not redundant afterall.

      Cheers!

      CarloE

      Reply
  12. Daniel

    April 18, 2013 at 9:22 pm

    This site was… how do I say it? Relevant!

    ! Finally I’ve found something which helped me. Cheers!

    Reply
    • Mynda Treacy

      April 19, 2013 at 8:43 am

      Cheers, Daniel 🙂 Glad you like it.

      Reply
  13. Steve

    October 26, 2012 at 2:09 am

    Shouldn’t grand total in example 4 be 1,349? …very confusing.

    Reply
    • Mynda Treacy

      October 26, 2012 at 9:53 am

      Hi Steve,

      Thanks for your feedback and sorry for the confusion. The total is correct, it’s just that the image doesn’t show rows 2:23. I have improved the image to hopefully make it clearer that there are hidden rows.

      Kind regards,

      Mynda.

      Reply
  14. shanthi mohan

    October 5, 2012 at 11:24 am

    Hi

    Your explanation is quite simple and impressive. Thanks for the great work.

    Reply
    • Mynda Treacy

      October 5, 2012 at 3:09 pm

      Cheers, Shanthi 🙂

      Reply
  15. Raghu

    September 18, 2012 at 3:18 am

    Hi! After sorting the table in alphabetical wise, In the Sub Total Tab, along with other boxes, if we also tick the “Page Break Between Groups” , it will automatically adjust page wise. It will be very easy to take print outs.
    Further, select the top row(Heading) in the “Print Titles” Tab, so that the top row is automatically repeated in every page.
    Once done, we can also convert the whole thing in to a PDF and mail, the end user will find it very convenient to use it, by taking prints, without taking any trouble of once again setting the page etc.,

    oooph!!!

    Reply
    • Mynda Treacy

      September 18, 2012 at 7:50 am

      🙂 Cheers, Raghu. They’re great ideas.

      Reply
  16. Ann Ferretti

    August 27, 2012 at 11:51 pm

    Hello, I am trying to use the SUBTOTAL function for more than one sheet in a large, filtered Excel file. It works perfectly on one sheet but does not work at all on subsequent sheets.

    Reply
    • Mynda Treacy

      August 28, 2012 at 12:23 pm

      Hi Ann,

      The SUBTOTAL function will not work across multiple worksheets. One solution is to put an individual SUBTOTAL on each sheet and then use the SUM function to add them up across the multiple sheets.

      Alternatively you can use this 3D SUMIF function to sum based on specific criteria.

      I hope that helps.

      Kind regards,

      Mynda.

      Reply
  17. Rasim Quliyev

    August 23, 2012 at 11:45 pm

    Thanks a lot.

    Reply
    • Mynda Treacy

      August 24, 2012 at 6:12 pm

      You’re welcome, Rasim 🙂

      Reply
  18. ajay singh

    August 19, 2012 at 8:05 pm

    Hi,

    I just saw a table kind of thing named subtotal in named range option.
    I want to know how can i do the same kind of wonder.

    thanks for this kind of support to the learner.

    Reply
    • Mynda Treacy

      August 19, 2012 at 9:43 pm

      Hi Ajay,

      Are you referring to Excel Tables?

      Kind regards,

      Mynda.

      Reply
  19. Abhishek

    July 24, 2012 at 3:06 pm

    You are superbbbbbbbbbbbbbb…………

    Reply
    • Mynda Treacy

      July 25, 2012 at 8:24 am

      🙂 Wow! Thanks, Abhishek.

      Reply
  20. Shivraj Singh Rajput

    June 13, 2012 at 3:14 pm

    Your’s Online Training is very useful for me. But I can’t pay for master training because of My condition is not allow to me for paying sorry………

    Thanks

    Reply
  21. Ken

    March 28, 2012 at 4:12 am

    An interesting and helpful website.

    Reply
  22. Martin P

    January 14, 2012 at 2:58 am

    Excellent book for excel users

    Reply
    • Mynda Treacy

      January 14, 2012 at 8:28 pm

      Thanks Martin 🙂

      Reply
  23. JAIR

    January 3, 2012 at 8:33 pm

    THANKS

    Reply
  24. Karen

    November 8, 2010 at 3:32 pm

    wow. great explanation.

    Reply
  25. badmash

    October 23, 2010 at 10:42 pm

    I just signed up to your blogs rss feed. Will you post more on this subject?

    Reply
    • Philip Treacy

      October 25, 2010 at 8:37 am

      Hi Badmash,

      yes we will be posting more on this and many other topics.

      You can get access to our training by signing up for free here FREE Office Training

      Regards

      Phil

      Reply

Trackbacks

  1. Excel COUNT, COUNTA and COUNTBLANK Functions • My Online Training Hub says:
    September 15, 2014 at 8:16 pm

    […] Use the SUBTOTAL Function […]

    Reply
  2. Excel Formulas - My Online Training Hub says:
    September 9, 2014 at 10:07 pm

    […] SUBTOTAL Explained […]

    Reply
  3. Save Time With Excel 2007 Tables says:
    December 10, 2010 at 2:02 pm

    […] Total formulas use the SUBTOTAL function so that if you Filter your table the Totals will only SUM the visible […]

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Current ye@r *

Leave this field empty

Sidebar

More results...

Featured Content

  • 10 Common Excel Mistakes to Avoid
  • Top Excel Functions for Data Analysts
  • Secrets to Building Excel Dashboards in Less Than 15 Minutes
  • Pro Excel Formula Writing Tips
  • Hidden Excel Double-Click Shortcuts
  • Top 10 Intermediate Excel Functions
  • 5 Pro Excel Dashboard Design Tips
  • 5 Excel SUM Function Tricks
  • 239 Excel Keyboard Shortcuts

100 Excel Tips and Tricks eBook

Download Free Tips & Tricks

Subscribe to Our Newsletter

Receive weekly tutorials on Excel, Power Query, Power Pivot, Power BI and More.

We respect your email privacy

Guides and Resources

  • Excel Keyboard Shortcuts
  • Excel Functions
  • Excel Formulas
  • Excel Custom Number Formatting
  • ALT Codes
  • Pivot Tables
  • VLOOKUP
  • VBA
  • Excel Userforms
  • Free Downloads

239 Excel Keyboard Shortcuts

Download Free PDF

Free Webinars

Excel Dashboards Webinar

Watch our free webinars and learn to create Interactive Dashboard Reports in Excel or Power BI

Click Here to Watch Now

mynda treacy microsoft mvpHi, I'm Mynda Treacy and I run MOTH with my husband, Phil. Through our blog, webinars, YouTube channel and courses we hope we can help you learn Excel, Power Pivot and DAX, Power Query, Power BI, and Excel Dashboards.

Blog Categories

  • Excel
  • Excel Charts
  • Excel Dashboard
  • Excel Formulas
  • Excel PivotTables
  • Excel Shortcuts
  • Excel VBA
  • General Tips
  • Online Training
  • Outlook
  • Power Apps
  • Power Automate
  • Power BI
  • Power Pivot
  • Power Query
microsoft mvp logo
trustpilot excellent rating
Secured by Sucuri Badge
MyOnlineTrainingHub on YouTube Mynda Treacy on Linked In Mynda Treacy on Instagram Mynda Treacy on Twitter Mynda Treacy on Pinterest MyOnlineTrainingHub on Facebook
 

Company

  • About My Online Training Hub
  • Disclosure Statement
  • Frequently Asked Questions
  • Guarantee
  • Privacy Policy
  • Terms & Conditions
  • Testimonials
  • Become an Affiliate

Support

  • Contact
  • Forum
  • Helpdesk – For Technical Issues

Copyright © 2023 · My Online Training Hub · All Rights Reserved. Microsoft and the Microsoft Office logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries. Product names, logos, brands, and other trademarks featured or referred to within this website are the property of their respective trademark holders.