Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

How to Use Array Formula in Google Sheets

· 5 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

Array formulas in Google Sheets let you perform calculations on an entire range of cells at once, instead of writing a separate formula in each row. This saves time, reduces errors, and makes your spreadsheets easier to maintain. With a single ARRAYFORMULA, you can apply a function to hundreds or thousands of rows, and it will automatically expand the result down the column. This guide walks you through the basics, common use cases, and pitfalls to avoid.

What You'll Need

  • A Google account with access to Google Sheets.
  • A spreadsheet with data you want to calculate (e.g., a list of numbers, dates, or text).
  • Basic familiarity with regular formulas like SUM or IF.

Step-by-Step

  1. Open your Google Sheet. Go to sheets.google.com and open the spreadsheet containing your data. If you're starting fresh, create a new sheet and enter some sample data in columns A and B (for example, quantities in A2:A10 and prices in B2:B10).
  2. Identify the range you want to process. Decide which cells contain the input data. For instance, if you have numbers in A2:A10 and you want to double each value, your range is A2:A10.
  3. Select the cell where you want the result to start. Click on an empty cell, usually in the same row as your first data row (e.g., C2). The array formula will automatically fill down from there.
  4. Type the ARRAYFORMULA function. Start with =ARRAYFORMULA(. Then write the operation you want to apply to the range. For example, to double the values in A2:A10, type =ARRAYFORMULA(A2:A10*2).
  5. Press Enter. Google Sheets will display the results in the cells below, automatically filling down to match the length of the input range. You'll see a blue border around the result range, indicating it's part of an array formula.
  6. Use ARRAYFORMULA with functions that normally handle single values. For example, to apply an IF condition to a range, write =ARRAYFORMULA(IF(A2:A10>5, "High", "Low")). This will check each cell in A2:A10 and return "High" or "Low" for each.
  7. Combine ARRAYFORMULA with other functions. You can nest functions like SUM, AVERAGE, or even VLOOKUP. For instance, to sum the products of two ranges, use =ARRAYFORMULA(SUM(A2:A10*B2:B10)). This multiplies each corresponding pair and then sums the results.
  8. Use ARRAYFORMULA with text operations. For example, to combine first names in A2:A10 and last names in B2:B10, type =ARRAYFORMULA(A2:A10 & " " & B2:B10). This will concatenate each row's values.
  9. Use ARRAYFORMULA with dates. To add 7 days to a list of dates in A2:A10, use =ARRAYFORMULA(A2:A10 + 7). Google Sheets will output date values in the result cells.
  10. Edit or delete an array formula. To modify it, click on the cell where you originally typed the formula (the top-left of the result range). Make your changes and press Enter. To remove it, select that cell and press Delete. You cannot edit individual cells in the result range directly.

Common Mistakes

  • Forgetting the equals sign or parentheses. Always start with =ARRAYFORMULA( and close with ).
  • Using ranges of different sizes. If you multiply A2:A10 by B2:B9, the formula will return an error because the ranges don't match. Ensure all ranges have the same number of rows (or columns).
  • Placing the formula in a cell that already has data. The array formula will overwrite anything below it. Make sure the cells below are empty.
  • Using ARRAYFORMULA with functions that already handle arrays. Some functions like SUM or AVERAGE are already array-aware. Wrapping them in ARRAYFORMULA is unnecessary and can cause confusion. For example, =SUM(A2:A10) works fine without ARRAYFORMULA.
  • Forgetting to use "*" for multiplication. In Google Sheets, you must use the asterisk (*) for multiplication, not an x.

Tips

  • Use absolute references when copying formulas. If you copy an array formula to another column, use $ to lock the range, e.g., =ARRAYFORMULA($A$2:$A$10*2).
  • Combine with IFERROR to handle blanks. For example, =ARRAYFORMULA(IFERROR(1/A2:A10, "")) returns an empty string for any division by zero.
  • Use ARRAYFORMULA with QUERY for complex data manipulation. You can wrap a QUERY result in ARRAYFORMULA to perform additional calculations on the returned data.
  • Leverage the "Ctrl+Shift+Enter" shortcut (Windows) or "Cmd+Shift+Enter" (Mac). Typing this after entering a formula automatically wraps it in ARRAYFORMULA.
  • Test on a small range first. Before applying to a huge dataset, test on a few rows to ensure the formula works as expected.

Troubleshooting

  • Formula returns #N/A or #VALUE! This usually means a range mismatch or an invalid operation. Check that all ranges have the same dimensions and that you're not mixing text with numbers in a math operation.
  • Formula only returns one value. If you see only the first result and no expansion, you might have forgotten to use ARRAYFORMULA, or you're using a function that doesn't support array output. Ensure you typed =ARRAYFORMULA( correctly.
  • Results are not updating when data changes. Google Sheets recalculates automatically, but if you have a large sheet, it might be slow. Try pressing Ctrl+R (or Cmd+R on Mac) to force a refresh.
  • Error: "Array result was not expanded because it would overwrite data in C5". This means there's something in the cell below your formula. Clear the conflicting cells or move your formula to a column with empty space below.
  • Formula works but shows a #REF! error. This often happens when you delete rows or columns that are part of the array. Check the range references and adjust them if needed.

Frequently Asked Questions

1. Can I use ARRAYFORMULA with VLOOKUP?
Yes, you can. For example, =ARRAYFORMULA(VLOOKUP(A2:A10, D:E, 2, FALSE)) will look up each value in A2:A10 and return the corresponding value from column E.

2. Does ARRAYFORMULA work with text and numbers?
Yes, it works with any data type as long as the operation is valid. For text, use concatenation (&). For numbers, use arithmetic operators.

3. Can I use ARRAYFORMULA inside another function like SUM?
Yes, you can nest it. For example, =SUM(ARRAYFORMULA(A2:A10*B2:B10)) multiplies the ranges element-wise and then sums the result. However, in many cases you can omit the ARRAYFORMULA wrapper and just use =SUMPRODUCT(A2:A10, B2:B10).

4. How do I edit an array formula?
Click on the cell where you originally entered the formula (the top-left of the result range). Edit it in the formula bar and press Enter. You cannot edit individual result cells.

5. Why does my array formula show a green triangle?
This is a warning that the formula may not be intended. Click the triangle to see the warning. It often appears when the formula is not in the top-left cell of the result range. Move it to the correct cell.

6. Can I use ARRAYFORMULA with conditional formatting?
No, conditional formatting uses its own custom formula rules, not ARRAYFORMULA. However, you can use ARRAYFORMULA to create a helper column that evaluates conditions, then apply conditional formatting based on that helper column.