The INDEX Function returns a value from the row and column you designate within a worksheet area. It performs a table lookup just like VLOOKUP or HLOOKUP but is more powerful.

The INDEX function is a computer program that you run from a worksheet cell formula. It returns a value from the row and column you designate within a worksheet range or array. In other words, it is table lookup just like VLOOKUP except you tell it what row and column to return information from within the table (i.e. range or array). In VLOOKUP you only told it the column to return the info from. You run the INDEX worksheet function by typing its name in a formula then followed by the information it is suppose to use. The INDEX worksheet function is used in applications when you have to look up prices, name information, scientific data anything that is contained in a table. Its advantage over VLOOKUP is that it can be used in conjunction with the MATCH function thus allowing what is looked up to be elsewhere then the first column of the range or array (i.e. table). It can also be used to merge two tables together transferring information from one to the other just like VLOOKUP.

Whenever you type a formula in a worksheet cell, this is called syntax or grammar. The general INDEX function syntax has a format like this when you type it in a worksheet cell:

=INDEX(reference,[row_num],[column_num])

Where reference,[row_num],[column_num] are called the function argument list. Remember, you are running a computer program at this point so the program needs information to operate and that is why there is an argument list. When you see an argument list and you see square brackets [ ] around the argument name, this means the argument is optional and you do not have to include it when typing unless you need it. So for the syntax above, you need to include 2 arguments for the INDEX worksheet function when typing it in a worksheet cell formula in order for it to calculate correctly. If row_num is omitted you need to put the col_num. If the col_num argument is omitted you need to put the row_num argument. What argument values can be used are discussed below. Remember functions expect certain things in their argument lists, if you do not put the correct information in the list they will generate an error when run.

- reference: This is a reference to the range containing your data. It can also be an array. For example, A1:B10 or a range name like sales.
- row_num (Optional): Designates the row in the lookup range in which to return a value. Make this argument 0 or blank if you wish to return an entire column of data. Be sure to designate the column if making 0 or blank.
- column_num (Optional): Designates the column in the range in which to return a value. Make this argument 0 or blank if you wish to return an entire row. Be sure to designate the row if making 0 or blank.

Since the INDEX function is a computer program, it runs when you press Enter to enter the formula that contains it. If any of the arguments are wrong, the function will return an error.

When typing the INDEX function in a worksheet cell formula, you need to replace the argument list with arguments separating each with a comma (,). Some typical arguments you can use are:

Cell Formula | Explanation |

= INDEX(G1:J5, 2, 2) | Returns the value from row 2 column 2 in the designated range. Remember the row and column numbers are relative to the range not the worksheet column headers. |

= SUM( INDEX( G1:J5, 0, 4 ) ) | Return the entire column 4 from the designated range. Most of the time the reason why you return a whole column is to use it as input to another function like SUM. In this example INDEX is nested inside of SUM to provide it the values to sum. |

= SUM( INDEX( G1:J5, 2, 0) ) | Return the entire row 2 from the designated range. Most of the time the reason why you return a whole row is to use it as input to another function like SUM. In this example INDEX is nested inside of SUM to provide it the values to sum. |

= INDEX( Sales, 2, 2 ) | Returns the value from row 2 column 2 in the designated range named Sales.* |

= Index( A1:F5, Match( "Widget1", B1:B5, 0 ), MATCH("Q4", A1:D1, 0 ) ) | Nest the Match worksheet function inside the INDEX function to find the row and column number that Index will need to return a value. Notice Match is looking in the second column of the range, not the first, for the position of Widget1. It is also scanning the headers of the table for the position of Q4. |

* It is possible to name a cell or group of cells on a worksheet and use that name in place of a range reference or cell reference. Consult Excel help on how to name a cell.

The worksheet seen below contains some typical worksheet formulas that run the INDEX worksheet function. Pay close attention to the argument list and the syntax used to write the formula.

A | B | C | D | |

1 | ||||

2 | ||||

3 | Item | RegionA | RegionB | RegionC |

4 | Widget1 | 100 | 200 | 150 |

5 | Widget2 | 200 | 300 | 250 |

6 | Widget3 | 300 | 400 | 350 |

7 | ||||

8 | Find Widget2,RegionA in the table which is row 3, column 2 relative to the table not columns on worksheet | |||

9 | Widget2, RegionA | 200 | = Index( A3:A6, 3, 2) | |

10 | ||||

11 | Use MATCH worksheet function to locate RegionB header position and Widget2 row position. Notice how MATCH function is being used to get the row and column positions for the INDEX function. Using MATCH, their positions could shift and the formula would adapt automatically. | |||

12 | Widget2, RegionB | 300 | = Index(A3:A6, Match( "Widget2", A3:A6, 0), Match( "RegionB", A3:D3, 0) ) | |

13 | ||||

14 | Use the MATCH worksheet function to locate RegionA header position in row 3 for INDEX function and leave row index for INDEX function 0. This will return that entire column of the table that includes RegionA header. SUM function will then add the range values being returned by INDEX which is B3:B6. Do not be afraid to include headers in values being summed, SUM function ignores text. Easier to create more advanced formulas if you leverage this concept. | |||

15 | Sum of RegionA | 600 | = Sum( Index( A3:A6, 0, Match( "RegionA" , A3:D3 ,0) ) ) | |

16 | ||||

17 | ||||

18 |

- If your information is always in the same place in a range, use numbers to designate the row and column index.
- Use the MATCH function in place of the row_num and/or column_num arguments if you have to search for a header that marks a column or some record name that marks a row. MATCH returns the index (position number) of an element in a row or column which can then be used to designate the row or column of your range or array that contains the value you are after.

Need Help? Please call us at 1.805.498.7162

Hands-On Excel Training Services

Microsoft Excel Products

EMAGENIT Company Information

US Military Discounts

Copyright © 2002-2020

EMAGENIT All Rights Reserved