### Defining a Range name in Google Sheets

In Google Sheets, defining a name is a little different.

1. Click the first column header of your source data, then press Ctrl-Shift-Right Arrow (Command-Shift-Right Arrow on the Mac). That selects the row of column headers.
2. Press Ctrl-Shift-Down Arrow (Command-Shift-Down Arrow on the Mac). That selects the actual data.
3. Click the Data menu, then select Named and protected ranges.
4. In the Name and protected ranges box on the right, type data, then click Done.

## Entering the Formula

To enter the formula, go to the Sales Amounts worksheet and click in B5.

Enter the formula:

=VLOOKUP(A5,data,8,FALSE)

Press Enter.

The result should be 40. To fill in the values down the column, click back on B5, if necessary. Put the mouse pointer on the AutoFill dot in the cell’s lower-right corner, so the mouse pointer becomes a cross hair.

Double-click to fill the values down the column.

If you want, you can run the VLOOKUP function in the next few columns to extract other fields, like last name or state.

## Using MATCH

The MATCH function is doesn’t return the value of data to you; you provide the value that you’re looking for, and the function returns the position of that value. It’s like asking where is #135 Main Street, and getting the answer that it’s the 4th building down the street.

### Syntax

The syntax of the MATCH function is:

=MATCH(lookup value, table range, [match type])

The arguments are:

• Lookup value. The cell that has the unique identifier.
• Table range. The range of cells you’re searching.
• Match type. Optional. It’s how you specify how close of a match you want, as follows:
 Next highest value -1 Values must be in descending order. Target value 0 Values can be in any order. Next lowest value 1 Default type. Values must be in ascending order.

As with the VLOOKUP function, you’ll probably find the MATCH function easier to use if you apply a range name. Go to the Source Data sheet, select from B4 (column header for order #) to the bottom, click in the Name box above column A, and call it order_number. Note that the values are in ascending order.

Go to the Match tab of the worksheet. In B5, enter the MATCH function:

=MATCH(A5,order_number,1)

If you didn’t define a range name, you’d write the function as:

=MATCH(A5,'Source Data'!A5:A203,0)

Either way, you can see that this is in the 14th position (making it the 13th order).

## Using INDEX

The INDEX function is the opposite of the MATCH function and is similar to VLOOKUP. You tell the function what row and column of the data you want, and it tells you the value of what’s in the cell.

### Syntax

The syntax of the INDEX function is:

=INDEX(data range, row number, [column number])

The arguments are:

• Data range. Just like the other two functions, this is the table of data.
• Row number. The row number of the data, which is not necessarily the row of the worksheet. If the table range starts on row 10 of the sheet, then that’s row #1.
• Column number. The column number of the data range. If the range starts on column E, that’s column #1.

Excel’s documentation will tell you that the column number argument is optional, but the row number is sort of optional, too. If the table range has only one row or one column, you don’t have to use the other argument.

Go to the Index sheet of the workbook and click in C6. We first want to find what’s contained in row 9, column 3 of the table. In the formula, we’ll use the range name that we created earlier.

Enter the formula:

=INDEX(data,A6,B6)

It returns a customer’s last name: Strevell. Change the values of A6 and B6, and the result in C6 will show different results (note that many rows have the same states and product names).

## Conclusion

The ability of a worksheet to look at another worksheet and extract data is a great tool. This way, you can have one sheet that contains all the data you need for many purposes, then extract what you need for specific instances.