Google Sheets formulas are expressions that start with an equals sign (=) and perform calculations, manipulate data, or pull information from other cells. For example, typing =SUM(A1:A10) adds all numbers in cells A1 through A10. This guide explains how formulas work, how to write them, common functions, troubleshooting, and answers frequently asked questions.
How Google Sheets Formulas Work
Every formula in Google Sheets begins with =. After the equals sign, you enter a function name (like SUM) followed by parentheses containing arguments. Arguments can be cell references, numbers, text, or other functions. When you press Enter, Sheets calculates the result and displays it in the cell. The formula itself remains visible in the formula bar when the cell is selected.
For example, if you have numbers in cells A1, A2, and A3, typing =A1+A2+A3 adds them. You can also combine functions: =AVERAGE(B1:B5) returns the average of the range. Sheets supports standard math operators: +, -, *, /, and ^ for exponentiation.
Essential Functions for Beginners
Start with these core functions that cover most everyday tasks:
- SUM:
=SUM(A1:A10)adds all values in the range. - AVERAGE:
=AVERAGE(B1:B10)calculates the mean. - COUNT:
=COUNT(C1:C10)counts numeric entries. - COUNTA:
=COUNTA(D1:D10)counts non-empty cells (including text). - IF:
=IF(E1>10, "High", "Low")returns one value if true, another if false. - VLOOKUP:
=VLOOKUP(F1, A:B, 2, FALSE)finds a value in the first column and returns a value from the same row in a specified column. - CONCATENATE:
=CONCATENATE(G1, " ", H1)joins text from cells.
These functions are available in Excel as well, but the syntax is identical. In Excel, VLOOKUP works the same way, but Google Sheets also has XLOOKUP (available in newer Excel versions) which is more flexible.
How to Write and Edit Formulas
To enter a formula, click a cell, type = and then the formula. As you type, Sheets suggests functions and shows a brief description. Press Enter to confirm. To edit, double-click the cell or click it and edit in the formula bar. You can also use the function menu: Insert > Function > Math, Logical, etc., to browse categories.
For ranges, you can type them manually (e.g., A1:A10) or select cells with the mouse while typing. Sheets automatically inserts the range. Use absolute references (with $, like $A$1) when you want a reference not to change when copying the formula to other cells. For example, =B1*$C$1 multiplies each B value by the constant in C1.
Common Formula Errors and How to Fix Them
Errors appear in the cell and often start with #. Here are the most common:
- #DIV/0!: Division by zero. Check if the denominator is zero or empty.
- #N/A: VLOOKUP or other lookup didn’t find a match. Verify the lookup value exists and the range is correct.
- #REF!: A referenced cell was deleted. Rebuild the formula or undo the deletion.
- #VALUE!: Wrong data type, like adding text to a number. Ensure all arguments are numeric.
- #NAME?: Misspelled function name or missing quotes around text. Check spelling and use double quotes for text strings.
To debug, click the cell and look at the formula bar. Use the Trace Precedents and Trace Dependents tools under the Formulas menu to see which cells affect the formula. For complex errors, break the formula into smaller parts in separate cells.
Using Formulas with Real Data: Examples
Suppose you have a sales sheet with columns: A = Product, B = Price, C = Quantity. To calculate total revenue per product, in D2 enter =B2*C2 and drag down. To get total revenue, use =SUM(D2:D100).
For a gradebook with scores in B2:B20, the average is =AVERAGE(B2:B20), and the highest is =MAX(B2:B20). To count how many students scored above 80, use =COUNTIF(B2:B20, ">80").
To look up a product price by name, with names in A2:A100 and prices in B2:B100, use =VLOOKUP("Widget", A2:B100, 2, FALSE). This returns the price of the product named “Widget”.
Google Sheets vs. Excel: Formula Differences
Most formulas are identical between Google Sheets and Microsoft Excel. However, there are differences:
- Function names: Some functions have different names, e.g., Google Sheets uses
SUMIFandCOUNTIFjust like Excel, but Excel hasXLOOKUP(2021/365) while Sheets usesVLOOKUPorXLOOKUP(Sheets added XLOOKUP in 2022). - Array formulas: In Excel, you may need Ctrl+Shift+Enter for older array formulas; Sheets uses
ARRAYFORMULAto force array behavior, e.g.,=ARRAYFORMULA(A1:A10*B1:B10). - Dynamic arrays: Excel 365 automatically spills results; Sheets requires
ARRAYFORMULAfor similar behavior. - Menu paths: In Sheets, functions are under Insert > Function; in Excel, under Formulas tab > Insert Function.
For most basic tasks, you can copy a formula from one to the other without changes.
Advanced Formulas: Logical, Text, and Lookup
Beyond basics, you can combine functions for powerful results:
- Nested IF:
=IF(A1>90, "A", IF(A1>80, "B", "C"))assigns grades. - SUMIF:
=SUMIF(B2:B20, "East", C2:C20)sums C values where B equals “East”. - INDEX/MATCH:
=INDEX(B2:B100, MATCH("Widget", A2:A100, 0))is a more flexible lookup than VLOOKUP. - LEFT/RIGHT/MID:
=LEFT(A1, 3)extracts first 3 characters. - TRIM:
=TRIM(A1)removes extra spaces.
To combine text and numbers, use =CONCATENATE("Total: ", TEXT(SUM(C2:C20), "$0.00")) to format the number as currency.
Frequently Asked Questions
How do I copy a formula down a column?
Click the cell with the formula, then hover over the bottom-right corner until you see a small blue square (the fill handle). Click and drag down to fill the formula into adjacent cells. Alternatively, select the cell, press Ctrl+C, then select the range and press Ctrl+V. On Mac, use Cmd+C and Cmd+V.
Why is my formula showing as text?
This usually happens if the cell is formatted as plain text or if you typed a space before the equals sign. Select the cell, go to Format > Number > Automatic, and ensure the formula starts with = with no leading space. If it still shows text, re-enter the formula.
How do I use a formula across different sheets?
Reference another sheet by its name followed by an exclamation mark. For example, =Sheet2!A1 gets cell A1 from Sheet2. If the sheet name has spaces, use single quotes: ='My Sheet'!A1. You can also click the other sheet tab while building the formula.
Can I use formulas to conditionally format cells?
Yes, but conditional formatting uses custom formulas. Select the range, go to Format > Conditional formatting, choose “Custom formula is”, and enter a formula like =A1>100. The formula is relative to the first cell in the selected range. This is different from Excel, where the path is Home > Conditional Formatting > New Rule.
What does the $ sign do in a formula?
The dollar sign creates an absolute reference, locking the row, column, or both when copying. $A$1 locks both, $A1 locks the column only, and A$1 locks the row. This is essential when you want a constant reference to remain fixed.
Are Google Sheets formulas case-sensitive?
No, function names are not case-sensitive, but text comparisons in functions like IF and VLOOKUP are case-insensitive by default. If you need case-sensitive matching, use EXACT or FIND instead of SEARCH.
Related
- Random 10 Digit Number: How to Generate One
- Random 16-Digit Number: How to Generate One
- How to Add Default Border in Excel
Try it: the Date Difference Calculator: days, months, years and weekdays between two dates, with the DATEDIF formulas.
More in How-to basics
- Power Query Absolute Value: How to Use Number.AbsIn Power Query, use the M function Number.Abs to return a number’s absolute value: for example, Number.Abs(-25) returns…
- LEGO Inventory Spreadsheet: Track Sets, Parts, and GapsA LEGO inventory spreadsheet is a workbook for recording the sets and individual pieces you own, or for…
- Microsoft Word Styles: How to Apply and Customize ThemTo use styles in Microsoft Word, place the cursor in a paragraph and choose a style from Home…
- Node.js Generate Random 6 Digit Number: 3 WaysTo generate a random 6-digit number in Node.js, use Math.floor(100000 + Math.random() * 900000). This gives you an…
- Google Sheets: How to Lock Cells From EditingTo lock cells in Google Sheets, select the cells, then choose Data > Protect sheets and ranges. In…
- Freeze Header in Excel: Shortcut Key and How to Use ItTo freeze the header row in Excel for Microsoft 365 on Windows, press Alt, then W, F, and…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.