Sub topic 7
Combining Several Ranges and Values
Prerequisites and the working model
Assume you can enter formulas and understand cell addresses such as B2 and ranges such as B2:B6. A function argument is one input inside a function's parentheses. Google Sheets lets you pass several arguments to one function by separating them with commas.
A range argument represents multiple cells. A literal argument is a value typed directly into the formula. A cell reference argument points to one cell.
For example, this formula has three arguments:
=SUM(B2:B6, D2:D6, 100)It adds every numeric value in B2:B6, every numeric value in D2:D6, and the literal number 100.
Combining ranges with `SUM`
Suppose a sheet contains two groups of expenses:
| A | B | C | D |
|---|---|---|---|
| Item | January | Item | February |
| Rent | 1200 | Rent | 1200 |
| Food | 350 | Food | 425 |
| Travel | 100 | Travel | 75 |
| Supplies | 80 | Supplies | 95 |
| Other | 40 | Other | 50 |
To total both months, use:
=SUM(B2:B6, D2:D6)The result is 3615. The comma does not add a separator value. It tells SUM that the formula contains another argument.
You can mix ranges, individual cells, and literal numbers:
=SUM(B2:B6, D2:D6, 100)This returns 3715. The extra 100 could represent a one-time adjustment that is not stored in either range.
You can also pass individual cells:
=SUM(B2, B3, D2, D3)This is valid, but a range is usually easier to read when the cells are next to each other.
The same pattern with other functions
Several aggregate functions accept multiple arguments. AVERAGE combines all numeric values from all supplied arguments before calculating the mean:
=AVERAGE(B2:B6, D2:D6)COUNT counts numeric cells across both ranges:
=COUNT(B2:B6, D2:D6)MIN and MAX find the smallest and largest numeric values across the supplied arguments:
=MIN(B2:B6, D2:D6)
=MAX(B2:B6, D2:D6)The function does not calculate one result per range and then combine those results. It treats the numeric values from all arguments as one collection. This matters for averages. For example, averaging two monthly averages can give the wrong overall average if the months contain different numbers of entries.
Common errors
Check each argument when a formula gives an unexpected result:
- A range may include a header or another text label. Aggregate functions generally ignore text in referenced cells.
- A number stored as text may not be treated as a number. For example, a value imported with a leading apostrophe can look numeric but be ignored by
SUM,AVERAGE,COUNT,MIN, andMAX. - A misspelled range or invalid reference can produce a reference error.
- A literal must be written as a number, not as an unquoted word. Text literals need quotation marks, although these basic aggregate functions normally ignore them.
If your spreadsheet locale uses semicolons as argument separators, replace commas with semicolons. The separator depends on the sheet's locale settings.
Exercise
Write one formula that adds the values in B2:B10, E2:E10, and the one-time value 250.
Show answer
=SUM(B2:B10, E2:E10, 250)