Sub topic 8
Combining several ranges, values, and whole columns
This chapter assumes you can write a single-range formula such as =SUM(B2:B6) and that you know how cells and ranges are addressed. Here you will pass more than one input to a function and use whole-column references.
Multiple arguments
SUM, AVERAGE, MIN, MAX, and COUNT all accept a list of arguments separated by commas. Excel allows up to 255 arguments. Each argument can be a range, a single cell, or a typed constant, and you can mix them.
=SUM(B2:B6, D2:D6, 100)This adds every number in both ranges and then adds 100. The ranges do not need to be the same size or next to each other.
The other functions combine their arguments the same way:
=MAX(B2:B6, D2:D6)
=MIN(B2:B6, F2, 0)
=COUNT(B2:B6, D2:D6)The first formula returns the largest value found in either range. The second returns the smallest of the numbers in B2:B6, the value in F2, and 0. The third counts the numeric cells in both ranges together.
AVERAGE pools its arguments
With several arguments, AVERAGE treats all the numeric cells as one group. It adds everything and divides by the total count of numbers. It does not average each range first.
=AVERAGE(B2:B6, D2:D6)
=SUM(B2:B6, D2:D6)/COUNT(B2:B6, D2:D6)Both formulas return the same value. If B2:B6 holds five numbers and D2:D6 holds two, the larger range has more influence on the result.
Typed values and cell values are treated differently
A value typed directly into the argument list is converted if possible. A value read from a cell is not.
| Input | Typed as an argument | Stored in a referenced cell |
|---|---|---|
| Number stored as text, such as "5" | Counted as 5 | Ignored |
| TRUE | Counted as 1 | Ignored |
| Blank cell | Not applicable | Ignored |
For example, =SUM("5", 2) returns 7, but if A1 holds the text 5, then =SUM(A1, 2) returns 2. This is a common reason for a total that looks too small. The chapter on data types covers it in more detail.
Overlapping ranges count twice
Excel does not remove duplicates between arguments. If two arguments cover the same cell, that cell is used twice.
=SUM(B2:B6, B4:B8)Cells B4:B6 are added twice here. Check argument ranges whenever a total looks higher than expected.
Whole-column references
A whole-column reference names an entire column, such as B:B. It picks up new rows automatically.
=SUM(B:B)
=COUNT(B:B)
=AVERAGE(B:B, D:D)Whole columns work well for lists that keep growing. Header text in B1 is ignored by these functions, because they skip text in ranges.
Keep these points in mind:
- Do not put the formula inside the column it reads.
=SUM(B:B)entered in B10 creates a circular reference, which Excel reports with a warning. - Notes or totals placed lower in the same column are included in the result.
- Whole-column references can slow very large workbooks, because Excel has to consider more cells. A bounded range such as
B2:B500is lighter.
Choosing between a range and a whole column
| Situation | Better choice |
|---|---|
| Data is a fixed block of known size | A bounded range, such as `B2:B6` |
| Rows are added regularly | A whole column, such as `B:B` |
| The column holds subtotals or notes | A bounded range |
Exercise
Column B holds the numbers 10, 20, 30 in B2:B4. Column D holds 40 and 50 in D2:D3. What do =SUM(B2:B4, D2:D3, 5) and =AVERAGE(B2:B4, D2:D3) return?
Show answer
The SUM returns 155, which is 60 + 90 + 5. The AVERAGE returns 30, which is 150 divided by 5 numbers. AVERAGE pools all five values. It does not average the two range averages.
Exercise
You enter =SUM(B:B) in cell B10. What happens, and how do you fix it?
Show answer
B10 is inside the range it sums, so Excel reports a circular reference. Move the formula to a cell outside column B, or change the reference to a bounded range such as B2:B9.