A User's Guide to Syntax for Spreadsheets

What is syntax and when would I use it in Excel or Google Sheets

Financial fluctuations
W. Geiersperger / Getty Images

The syntax of an Excel or Google Sheets spreadsheet function refers to the layout and order of the function and its arguments. A function in Excel and Google Sheets is a built-in formula. All the functions begin with the equal sign ( = ) followed by the function's name such as IF, SUM, COUNT, or ROUND. You need to use the correct syntax whenever you enter a function in Excel or Google Sheets or you'll likely get an error message.

A function's arguments refer to all the data or information required by a function. These arguments must be entered in the correct order.

The IF Function Syntax

As an example, the syntax of the IF function in Excel is:

=IF(Logical_test, Value_if_true, Value_if_false)

Parenthesis and Commas

In addition to the order of arguments, the term "syntax" also refers to the placement of round brackets or parenthesis surrounding the arguments and to the use of the comma as a separator between the individual arguments.

Note: Since the syntax of the IF function requires a comma to separate the three arguments of the function, you cannot use a comma as a separator in numbers greater than a thousand. If you do, Excel displays an alert dialog box telling you that it has found a problem with the formula or that too many arguments have been defined for this function.

Reading the IF Function's Syntax

By following the rules mentioned above, you can deduce that the IF function in Excel and in Google Sheets normally has three arguments arranged in the following order:

  1. Logical_test argument
  2. Value_if_true argument
  3. Value_if_false argument

If the arguments are placed in a different order, the function returns an error message or gives you an answer you were not expecting.

Required vs. Optional Arguments

One piece of information that the syntax does not relate is whether an argument is required or optional. In the case of the IF function, the first and second arguments—the Logical_test and the Value_if_true arguments—are required, while the third argument, the Value_if_false argument, is optional.

If the third argument is omitted from the function and the condition tested by the function's Logical_test argument evaluates to false, then the function displays the term FALSE in the cell where the function is located.