A function in Excel is a predefined formula with a name that takes values, called arguments, and returns a result. In =SUM(A2:A5), SUM is the function and A2:A5 is its argument.
That is all a function is: a named calculation you call instead of writing the arithmetic yourself. The rest of this page covers the exact structure, a worked example with real numbers, the difference between a function and a formula, and how to insert and combine functions.
What an Excel function looks like
Microsoft describes the structure this way: a function begins with an equal sign (=), followed by the function name, an opening parenthesis, the arguments separated by commas, and a closing parenthesis. Written as a template:
=FUNCTION_NAME(argument1, argument2, ...)
Here are the parts, using SUM as the example:
| Part | Example | Role |
|---|---|---|
| Equal sign | = | Tells Excel the cell holds a calculation, not plain text. |
| Function name | SUM | Selects which calculation to run. |
| Parentheses | ( ) | Enclose the arguments. |
| Arguments | A2:A5 | The values the function works on. |
| Commas | , | Separate one argument from the next. |
Function names are not case sensitive when you type them, so =sum(a2:a5) works the same as =SUM(A2:A5). One detail depends on your regional settings: some locales use a semicolon instead of a comma between arguments. If a formula from a web page fails with commas, try semicolons.
A worked example with SUM
Suppose cells A2 to A5 hold four numbers:
| Cell | Value |
|---|---|
| A2 | 10 |
| A3 | 20 |
| A4 | 30 |
| A5 | 40 |
Without a function, you would add them by hand:
=A2+A3+A4+A5
With a function, you hand the whole range to SUM:
=SUM(A2:A5)
Both return 100. The difference shows up when the list grows. Microsoft documents the syntax as SUM(number1, [number2], ...), where each argument can be a number, a cell reference or a range, and up to 255 arguments are allowed. A range like A2:A5 counts as one argument, so ten thousand rows still need one short formula.
You can also mix argument types. This formula adds a range, a single cell and a typed number:
=SUM(A2:A5, C2, 5)
If C2 holds 7, the result is 100 + 7 + 5 = 112. Microsoft also notes that SUM ignores text in the cells it adds, while a formula like =A1+B1+C1 can return a #VALUE! error when one of those cells contains text. That is a practical reason to prefer the function over the plus sign for long lists.
Function vs formula: what is the difference?
A formula is any entry that starts with = and calculates a value. A function is one ingredient a formula can use. According to Microsoft, a formula can contain any or all of these elements: functions, references, operators and constants.
| Entry | Formula? | Contains a function? |
|---|---|---|
=A1+B1 | Yes | No, only references and an operator |
=5*12 | Yes | No, only constants and an operator |
=SUM(A1:B1) | Yes | Yes, SUM |
=SUM(A1:B1)*2 | Yes | Yes, SUM, plus an operator and a constant |
So every function call sits inside a formula, but not every formula contains a function. People often use the two words loosely, and for everyday work that is fine.
Functions that make decisions: IF
Functions are not limited to arithmetic. IF checks a condition and returns one value when it is true and another when it is false. Microsoft documents it as IF(logical_test, value_if_true, [value_if_false]). Microsoft's own example is:
=IF(C2="Yes",1,2)
If C2 contains "Yes", the formula returns 1. If C2 contains anything else, it returns 2. The third argument is optional, but Microsoft states that if you leave it out the result is 0 when the test is false. If you want a different result for "false", write it out.
For a text-matching version of this idea, see Excel IF cell contains text.
Arguments can be other functions (nesting)
Microsoft lists the allowed argument types as numbers, text, logical values such as TRUE or FALSE, arrays, error values such as #N/A, and cell references. Arguments can also be constants, formulas or other functions. Putting a function inside another function's argument is called nesting.
Using the same cells as above, this formula combines IF and SUM:
=IF(SUM(A2:A5)>50, "High", "Low")
SUM(A2:A5) runs first and returns 100. The IF then tests 100 > 50, which is true, so the cell shows High. Change A5 to 0 and the sum becomes 60, still above 50. Change A3 and A5 to 0 as well and the sum is 10, so the cell shows Low.
There are two rules to keep in mind. First, per Microsoft, a nested function must return the same type of value that the argument uses. If an argument expects a number and the inner function returns text, Excel shows #VALUE!. Second, there is a limit on depth. Microsoft's "Using functions and nested functions" article says a formula can contain up to seven levels of nested functions. Some other Microsoft pages give a higher number, and the limit may differ by Excel version, so check the documentation for your version if you build deeply nested formulas.
How to insert a function in Excel
You have three ways to enter a function, and all of them produce the same formula text.
- Type it. Click a cell, type
=and the first letters of the name. Excel shows a drop-down list of valid functions, arguments and names that match, and you can pick one from the list. - Use the Formulas tab. Microsoft says all of Excel's functions are on the Formulas tab of the ribbon, grouped there for browsing.
- Use the Insert Function dialog. Click a cell and press Shift+F3. The dialog lists the available functions and shows a box for each argument, which helps when you do not remember the order.
After typing the closing parenthesis, press Enter. Excel calculates the result and shows it in the cell, while the formula itself stays visible in the formula bar.
Common functions to learn next
Once the structure is clear, every other function follows the same pattern: a name, parentheses and arguments. Two lookup functions are worth learning early because they save the most manual searching:
- How to use VLOOKUP in Excel covers the older lookup function, its four arguments and its usual errors.
- How to use XLOOKUP in Excel covers the newer replacement and how it differs.
If a function does not work
- The cell shows the formula text instead of a result. The entry is missing the leading
=, or the cell is formatted as Text. Re-enter it with the equal sign. #NAME?. Excel does not recognise the function name, often because of a typo or because the function does not exist in your Excel version.#VALUE!. An argument has the wrong type, for example text where a number is required, or a nested function that returns the wrong kind of value.- A message about the formula having a problem. Count the parentheses. Every opening parenthesis needs a closing one, and nested functions make that easy to get wrong.
Frequently asked questions
- What is the difference between a formula and a function in Excel?
- A formula is any entry that starts with an equal sign and calculates a value. A function is a predefined calculation with a name, such as SUM or IF, that you can use inside a formula. A formula can contain functions, references, operators and constants, so =A1+B1 is a formula with no function, and =SUM(A1:B1) is a formula built around one.
- What are arguments in an Excel function?
- Arguments are the values a function works on, written inside its parentheses and separated by commas. Microsoft lists numbers, text, logical values such as TRUE or FALSE, arrays, error values such as #N/A and cell references as valid arguments. Arguments can also be constants, formulas or other functions.
- Can a function in Excel have no arguments?
- Yes. Some functions take nothing, but you still type the parentheses. Microsoft's own example is PI(), which returns the value of pi (3.142...). Leaving the parentheses out makes Excel treat the name as something else, so the formula will not work as intended.
- How do I see a list of all Excel functions?
- Open the Formulas tab on the ribbon, where Excel groups its functions. You can also click a cell and press Shift+F3 to open the Insert Function dialog, which lists the available functions and walks you through each argument.