How to Use the INDEX Function in Excel
The INDEX function in Excel and Google Sheets is a vital tool that retrieves the value of a cell within a given range, determined by specified row and column numbers. This function proves exceptionally beneficial when handling large datasets to pinpoint specific data based on particular criteria.
Basic Syntax
The syntax for the INDEX function is straightforward:
=INDEX(array, row_num, [column_num])
- array: This is the cell range or array from which the value is extracted.
- row_num: This defines the row in the array from which to extract the value.
- column_num: (Optional) This identifies the column in the array from which to extract the value. If this parameter is omitted, the function returns the entire row specified by row_num.
Examples of Usage
Below are several examples to illustrate the utility of the INDEX function.
Example 1: Basic Usage
Imagine a dataset where column A lists student names and column B their respective scores. We aim to find the score for the student in the third row.
Name | Score |
---|---|
John | 85 |
Amy | 92 |
Michael | 78 |
The appropriate formula is:
=INDEX(B2:B4, 3)
This returns “78”, the score of the student in row 3.
Example 2: Retrieving a Specific Value
To refine the previous example, we want to fetch the score of the student named “Amy”.
This can be accomplished by combining the MATCH function with the INDEX function, as shown:
=INDEX(B2:B4, MATCH("Amy", A2:A4, 0))
This formula identifies “Amy” within the range A2:A4 and retrieves her score from column B.
Example 3: Returning an Entire Row
In some cases, the requirement may be to extract an entire row of data based on specific criteria. For instance, if we need all data for the student “John”:
=INDEX(A2:B4, MATCH("John", A2:A4, 0), 0)
This function call outputs the entire row of data relating to “John”.
These examples underscore the flexibility and efficacy of the INDEX function in Excel and Google Sheets, making it an indispensable tool for retrieving specific values, entire rows, or even columns as needed.
More information: https://support.microsoft.com/en-us/office/index-function-a5dcf0dd-996d-40a4-a822-b56b061328bd