Ms 04 Solved Assignment In Excel

The tutorial explains the specificities of Excel SUBTOTAL function and shows how to use Subtotal formulas to summarize data in visible cells.

In the previous article, we discussed an automatic way to insert subtotals in Excel by using the Subtotal feature. Today, you will learn how to write Subtotal formulas on your own and what advantages this gives to you.

Excel Subtotal function - syntax and uses

Microsoft defines Excel SUBTOTAL as the function that returns a subtotal in a list or database. In this context, "subtotal" is not just totaling numbers in a defined range of cells. Unlike other Excel functions that are designed to do only one specific thing, SUBTOTAL is amazingly versatile - it can perform different arithmetic and logical operations such as counting cells, calculating average, finding the minimum or maximum value, and more.

The SUBTOTAL function is available in all versions of Excel 2016, Excel 2013, Excel 2010, Excel 2007, and lower.

The syntax of Excel SUBTOTAL is as follows:

SUBTOTAL(function_num, ref1, [ref2],…)


  • Function_num - a number that specifies which function to use for the subtotal.
  • Ref1, Ref2, … - one or more cells or ranges to subtotal. The first ref argument is required, others (up to 254) are optional.

The function_num argument can belong to one of the following sets:

  • 1 - 11 ignore filtered-out cells, but include manually hidden rows.
  • 101 - 111 ignore all hidden cells - filtered out and hidden manually.
1101AVERAGEReturns the average of numbers.
2102COUNTCounts cells that contain numeric values.
3103COUNTACounts non-empty cells.
4104MAXReturns the largest value.
5105MINReturns the smallest value.
6106PRODUCTCalculates the product of cells.
7107STDEVReturns the standard deviation of a population based on a sample of numbers.
8108STDEVPReturns the standard deviation based on an entire population of numbers.
9109SUMAdds up the numbers.
10110VAREstimates the variance of a population based on a sample of numbers.
11111VARPEstimates the variance of a population based on an entire population of numbers.

In fact, there is no need to memorize all function numbers. As soon as you start typing a Subtotal formula in a cell or in the formula bar, Microsoft Excel will display a list of available function numbers for you.

For example, this is how you can make a Subtotal 9 formula to sum up the values in cells C2 to C8:

To add a function number to the formula, double-click on it, then type a comma, specify a range, type the closing parenthesis, and press Enter. The completed formula will look like this:

In a similar manner, you can write a Subtotal 1 formula to get an average, Subtotal 2 to count cells with numbers, Subtotal 3 to count non-blanks, and so on. The following screenshot shows a few other formulas in action:

Note. When you use a Subtotal formula with a summary function like SUM or AVERAGE, it calculates only cells with numbers ignoring blanks and cells containing non-numeric values.

Now that you know how to create a Subtotal formula in Excel, the main question is - why would one want to take the trouble of learning it? Why not simply use a regular function like SUM, COUNT, MAX, etc.? You will find the answer right below.

Top 3 reasons to use SUBTOTAL in Excel

Compared to the traditional Excel functions, SUBTOTAL gives you the following important advantages.

1. Calculate values in filtered rows

Because the Excel SUBTOTAL function ignores values in filtered-out rows, you can use it to create a dynamic data summary where subtotal values are re-calculated automatically according to the filter.

For example, if we filter the table to show sales only for the East region, the Subtotal formula will automatically adjust so that all other regions are removed from the total:

Note. Because both function number sets (1-11 and 101-111) ignore filtered out cells, you can use ether Subtotal 9 or Subtotal 109 formula in this case.

2. Calculate only visible cells

As you remember, Subtotal formulas with function_num 101 to 111 ignore all hidden cells - filtered out and hidden manually. So, when you use Excel's Hide feature to remove irrelevant data from view, use function number 101-111 to exclude values in hidden rows from subtotals.

The following example will help you gain more understanding of how it works: Subtotal 9 vs. Subtotal 109.

3. Ignore values in nested Subtotal formulas

If the range supplied to your Excel Subtotal formula contains any other Subtotal formulas, those nested subtotals will be ignored, so the same numbers won't be calculated twice. Awesome, isn't it?

In the screenshot below, the Grand Average formula ignores the results of the Subtotal formulas in cells C3 and C10, as if you used an Average formula with 2 separate ranges .

Using Subtotal in Excel - formula examples

When you first encounter SUBTOTAL, it may seem complex, tricky, and even pointless. But once you get down to brass tacks, you will realize that it's not that difficult to master. The following examples will show you a couple of helpful tips and inspirational ideas.

Example 1. Subtotal 9 vs. Subtotal 109

As you already know, Excel SUBTOTAL accepts 2 sets of functions numbers: 1-11 and 101-111. Both sets ignore filtered-out rows, but numbers 1-11 include manually hidden rows whereas 101-111 exclude them. To better understand the difference, let's consider the following example.

To total filtered rows, you can use either Subtotal 9 or Subtotal 109 formula like shown in the screenshot below:

But if have hidden irrelevant items manually by using the Hide Rows command on the Home tab > Cells group > Format > Hide & Unhide, or by right clicking the rows, and then clicking Hide, and now you want to total values only in visible rows, Subtotal 109 is the only option:

Other function numbers work in the same way. For example, to count non-blank filtered cells, either Subtotal 3 or Subtotal 103 formula will do. But only Subtotal 103 can properly count visible non-blanks if there are any hidden rows in the range:

Note. The Excel SUBTOTAL function with function_num 101-111 neglects values in hidden rows, but not in hidden columns. For example, if you use a formula like to sum numbers in a horizontal range, hiding a column won't affect the subtotal.

Example 2. IF + SUBTOTAL to dynamically summarize data

If you are creating a summary report or a dashboard where you have to display various data summary but you don't have space for everything, the following approach might be a solution:

  • In one cell, make a drop-down list containing the functions names such as Total, Max, Min, and so on.
  • In a cell next to the dropdown, enter a nested IF formula with the embedded Subtotal functions corresponding to the function names in the drop-down list.

For example, assuming the values to subtotal are in cells C2:C16, and the drop-down list in A17 contains Total, Average, Max, and Min items, the "dynamic" Subtotal formula is as follows:

And now, depending on what function your user selects from the drop-down list, the corresponding Subtotal function will calculate values in filtered rows:

Tip. If all of a sudden the drop-down list and the formula cell disappear from your worksheet, be sure to select them in the filter list.

Excel Subtotal not working - common errors

If your Subtotal formula returns an error, it's likely to be because of one of the following reasons:

- the function_num argument is other than an integer between 1 - 11 or 101 - 111; or any of the ref arguments contains a 3-D reference.

- occurs if a specified summary function has to perform a division by zero (e.g. calculating an average or standard deviation for a range of cells that does not contain a single numeric value).

- the name of the Subtotal function is misspelled - the easier error to fix :)

Tip. If you don't feel comfortable with the Excel SUBTOTAL function yet, you can use the built-in SUBTOTAL feature and have the formulas inserted for you automatically.

Finally, you are welcome to download the Excel Subtotal sample workbook containing all of the formulas we discussed in this tutorial.

You may also be interested in:

Although I find myself feeling relatively comfortable using Excel, especially with computing calculations, through these assignments I have found there is always something new to learn. Within the Excel assignments that we have done thus far some of the most unfamiliar computations that I learned would be how to compute correlation, finding the square of the smallest value, z score equations, computing t and z values, and finding sample mean/size.

The most frequent and major problem that I faced while working through these assignments was knowing which formula to use for certain computations. For me, the Excel website through Microsoft online was the most helpful tool to address and solve these formula issues. The website worked the best because not only did it have the equation, but it also included steps and examples for each equation. If there was information I could not find through Microsoft’s website, I usually turned to YouTube tutorials. These tutorials walked through the steps to help find whatever value I was trying to compute. This was a great help, because the tutorials walked through the examples right on Excel, so I knew exactly what to do when I went back to my workbook.

Spreadsheets are really common ways that businesses use to document their data or keep record of business related information. As a business major I have already used Excel in multiple business courses, so I know I will use the program in future classes as well, so the more I know the more beneficial it will be for me.


Leave a Reply

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