The array formula is a powerful function that can be used to create arrays of data. This function can be used to create arrays of any type of data, including text, numbers, and dates. The array formula can be used to create arrays of any size, and it can be used to create arrays of any shape.
To use the array formula in Google Sheets, you first need to create a sheet called “Sheet1”. Then, you need to add a new row to the sheet called “Sheet2”. Finally, you need to add a new column called “Data”.
In Sheet1, you first need to add the following code:
#include <stdio.h>
#define ARRAYFORMULA(x) {
int i; \ char* s; \ // x must be an integer value \ } // x must not contain any white-space characters.\
\begin{array}{l}[0]&=1\[1]&=2\[2]&=3\[3]&=4\[4]&=5\[5]&=6\[6]&=7\[7]&=8\[8]&=9\end{array}
How many times have you created a formula and copied it to the adjacent cells in your sheet? In Google Sheets, you can skip this step by using the ARRAYFORMULA function.
With ARRAYFORMULA in Google Sheets, you can return several values instead of just one. This lets you combine the function with others like SUM, SUMIF, IF, and more to obtain results for an entire cell range.
About Array Formulas
If you aren’t familiar with array formulas, you can simply break down the term. An array is a range of cells arranged in rows and columns. A formula is an equation of sorts that performs an action or calculation on the referenced cell(s).
So when you combine the two, an array formula lets you perform multiple calculations on a group of cells at once. You can obtain a single result or multiple results with an array formula based on the calculations you perform. But many find the greater value in the latter.
To make using array formulas easier, Google Sheets provides a function dedicated to it, the ARRAYFORMULA function.
Use the ARRAYFORMULA in Google Sheets
The syntax for the function is ARRAYFORMULA(array_formula) where the one and only argument is required. The argument can include a cell range, expression, or function for one or more arrays of the same size.
There are two ways to insert an ARRAYFORMULA formula in Google Sheets.
This first method is ideal when you’ve already typed your formula and realize you want to use the ARRAYFORMULA function instead. Or, for those times when you want to concentrate on the meat of the formula and worry about adding the ARRAYFORMULA function afterward.
With an ordinary formula entered into a cell, place your cursor in or on the formula in the Formula Bar. Then, press Ctrl+Shift+Enter on Windows or Command+Shift+Return on Mac. You’ll see your formula transform into an ARRAYFORMULA formula.
Simply press Enter or Return to apply the converted formula.
The next method for inserting an ARRAYFORMULA formula in Google Sheets is by entering it like any other formula. So, let’s look at some basic examples.
Basic ARRAYFORMULA Examples
For this first example, we’ll do a simple multiplication calculation for a cell range. We’ll take our Quantity Sold and multiply it by the Unit Price. To do this for our entire array, we would use the following formula:
While we have a small cell range for our calculation here, cells B2 through B6 multiplied by cells C2 through C6, imagine if you have hundreds of cells in the array. Rather than inserting a formula that you then need to copy down, just use the ARRAYFORMULA for the array.
For this next example, let’s toss in another function. We’ll add the formula for the IF function as the argument for ARRAYFORMULA. Using the formula below, we will display Bonus if the amount in the cell range F2 through F6 is above 20,000 and No Bonus if it’s not.
Again, we save a step by inserting a single formula that populates for the entire cell range.
In our final example, we’ll combine the SUMIF function with ARRAYFORMULA. Using the formula below, we sum the amounts in cells M2 through M16 if the values in cells O3 through O5 equal those in cells L2 through L16.
Now with this one simple formula, we’re able to get sales totals for only those three products we want. The formula for the ARRAYFORMULA function fills our cells for Shirts, Shorts, and Shoes correctly.
Here you have the basics of using the ARRAYFORMULA function in Google Sheets. So, you can experiment with more complex formulas to achieve the results you need.
Keep in mind this is one of those Google Sheets functions currently unavailable in Microsoft Excel, so take advantage of it!