Sub topic 2
Anatomy of a function call
This chapter assumes you can enter and edit values in cells, select cells and ranges with the mouse or keyboard, and know that a formula starts with an equals sign. It also builds on the previous chapter's idea of a range such as B2:B6. Here you learn the structure every function call shares, so the rest of the tutorial can focus on what each function does.
The parts of a function call
A function is a named routine that takes inputs and returns one value. A function call is the text you type to run it. Every call in this tutorial has the same shape:
=SUM(B2:B6, 100)| Part | Example | Role |
|---|---|---|
| Equals sign | `=` | Tells Excel the cell holds a formula, not text. |
| Function name | `SUM` | Selects which routine runs. |
| Opening parenthesis | `(` | Starts the argument list. It must follow the name directly. |
| Arguments | `B2:B6`, `100` | The inputs the function works on. |
| Separator | `,` | Divides one argument from the next. |
| Closing parenthesis | `)` | Ends the argument list. |
The cell displays the result, and the formula bar shows the formula text. Select the cell and look at the formula bar whenever you want to see what a result is built from.
Arguments
An argument is one input between the parentheses. Excel accepts several kinds, and you can mix them in one call.
| Kind | Example | What the function receives |
|---|---|---|
| Single cell reference | `B2` | The value in that cell. |
| Range | `B2:B6` | The values in every cell of the block. |
| Constant | `100` | The number you typed. |
| Expression | `B2*1.2` | The result of the calculation. |
| Another function call | `AVERAGE(D2:D6)` | The value that call returns. |
A range is a single argument, however many cells it covers. =SUM(B2:B6) has one argument and =SUM(B2, B3, B4, B5, B6) has five. Both add the same cells.
Each of the five functions in this tutorial takes one or more arguments, and the documentation writes the pattern like this:
SUM(number1, [number2], ...)Square brackets mark an argument as optional. number1 is required, so =SUM() is rejected. Excel allows up to 255 arguments in one call.
Worked example
Suppose B2:B6 holds 120, 80, 95, 60, and 145. These formulas show the argument kinds in use.
=SUM(B2:B6)
=SUM(B2:B6, 100)
=SUM(B2, B4, B6)
=MAX(B2:B6, 200)
=SUM(B2:B6)/COUNT(B2:B6)- The first formula returns 500, the total of the range.
- The second passes a range and a constant, so it returns 600.
- The third passes three single cells, so it adds 120, 95, and 145 and returns 360.
- The fourth gives MAX a range and a constant. The largest of all the values is 200, so it returns 200.
- The fifth divides one function's result by another's. It returns 100, the same as
=AVERAGE(B2:B6).
The fifth formula uses function calls as operands in an ordinary arithmetic expression. A function call is a value, so it can appear anywhere a number can.
Nesting
Nesting means placing one function call inside the argument list of another. Excel evaluates the inner call first and passes its result outward.
=ROUND(AVERAGE(B2:B6), 1)Excel first computes AVERAGE(B2:B6). It then hands that number to ROUND as the first argument, and 1 is the second argument (digits to keep). Read nested formulas from the innermost parentheses outward.
You can nest up to 64 levels, but deep nesting is hard to read and hard to debug. If you find yourself past three levels, consider splitting the work across helper cells.
Count parentheses when you nest. Every ( needs a matching ). Excel colors matching pairs as you edit, which helps you spot a misplaced one.
Separators and regional settings
The comma between arguments is the English-language default. Many regional settings, mainly those that write decimals with a comma, use a semicolon instead.
=SUM(B2:B6; D2:D6; 100)This is the same call as =SUM(B2:B6, D2:D6, 100). The separator is a property of your Excel's regional settings, not of the formula's meaning. If a formula from an online example is rejected, check which separator your installation expects. Excel stores the formula internally in a neutral form, so a workbook shared between users with different settings still works. Each person sees their own separator.
Names, case, and spacing
Function names are not case sensitive. =sum(b2:b6) and =SUM(B2:B6) do the same thing, and Excel usually converts a valid name to uppercase after you press Enter. If the name stays lowercase, Excel did not recognize it, which is a useful early warning.
Spaces inside the parentheses around arguments are ignored. This is allowed:
=SUM( B2:B6 , D2:D6 )Spaces change meaning in one situation. Between two references, a space is the intersection operator, which returns only the cells the two references share. =SUM(B2:B6 D2:D6) therefore does not add both columns. The ranges share no cells, so the result is #NULL!. Always put a comma between ranges.
A text constant must be wrapped in double quotes, for example "East". Numbers are never quoted. You will use quoted text in the conditional functions later in the tutorial.
Typing a call with Excel's help
Excel assists while you type:
- After
=and the first letters of a name, a list of matching functions appears. Press Tab to accept the highlighted one, which inserts the name and the opening parenthesis. - Once the opening parenthesis is in place, a tooltip shows the argument pattern with the current argument in bold.
- Selecting a range with the mouse while the cursor is inside the parentheses writes its reference for you. This avoids typos in cell addresses.
- Pressing F2 on a formula cell highlights each referenced range in a matching color, so you can check which cells the call reads.
Common errors in the call itself
Some mistakes are about the shape of the call, not about the data it reads.
| Entry | What happens | Fix |
|---|---|---|
| `=SUMM(B2:B6)` | Returns `#NAME?` because Excel does not know the name. | Correct the spelling. |
| `=SUM(B2:B6` | Missing closing parenthesis. Excel may offer a corrected formula or show a warning. | Add the `)`. |
| `=SUM(B2:B6))` | Extra closing parenthesis. Excel shows a message that the formula has a problem. | Remove the extra `)`. |
| `=SUM()` | No argument for a required input. Excel rejects the entry. | Supply at least one argument. |
| `=SUM(B2:B6 D2:D6)` | Space treated as intersection, result `#NULL!`. | Use a comma. |
| `=SUM(B2:B6; D2:D6)` | Rejected where the list separator is a comma. | Use your regional separator. |
#NAME? also appears when text that is not a function name or defined name sits in an argument without quotes. For example, =COUNTIF(A2:A6, East) fails where "East" works.
Quick reference for the five functions
All five share the same argument pattern and accept ranges, single cells, and constants. What differs is the value returned.
| Function | Returns |
|---|---|
| `SUM` | The total of the numbers. |
| `AVERAGE` | The mean of the numbers. |
| `MIN` | The smallest number. |
| `MAX` | The largest number. |
| `COUNT` | How many numeric cells there are. |
Because the structure is identical, once you can read one of these calls you can read all of them. The following chapters examine each function's return value and its handling of blanks, text, and errors.
Exercise
Identify the function name, the number of arguments, and the kind of each argument in =MAX(B2:B6, D2, 50). Then say what the formula returns if B2:B6 holds 12, 7, 30, 9, 21, D2 holds 44, and a user whose Excel uses semicolons as separators wants to enter the same formula.
Show answer
The function name is MAX and it has three arguments: the range B2:B6, the single cell reference D2, and the constant 50. The values considered are 12, 7, 30, 9, 21, 44, and 50, so the formula returns 50. With semicolon separators the user enters =MAX(B2:B6; D2; 50). The meaning is identical.
Exercise
A learner types =SUM(B2:B6 D2:D6) to add two columns and gets #NULL!. Explain why, and write the corrected formula.
Show answer
Excel treats the space between two references as the intersection operator, which returns only the cells the references share. B2:B6 and D2:D6 share no cells, so the result is #NULL!. The corrected formula is =SUM(B2:B6, D2:D6), with a comma separating the two arguments.