{"id":3401,"date":"2014-03-04T14:42:32","date_gmt":"2014-03-04T09:12:32","guid":{"rendered":"http:\/\/trumpexcel.com\/?page_id=3401"},"modified":"2023-09-29T15:22:41","modified_gmt":"2023-09-29T09:52:41","slug":"excel-index-function","status":"publish","type":"post","link":"https:\/\/trumpexcel.com\/excel-index-function\/","title":{"rendered":"Excel INDEX Function | Formula Examples + FREE Video"},"content":{"rendered":"<h2>Excel INDEX Function (Examples + Video)<\/h2>\n<p><img fetchpriority=\"high\" decoding=\"async\" class=\"alignnone wp-image-3259\" src=\"https:\/\/trumpexcel.com\/wp-content\/uploads\/2014\/03\/INDEX-FORMULA-EXCEL.png\" alt=\"Excel INDEX Function\" width=\"450\" height=\"327\" srcset=\"https:\/\/trumpexcel.com\/wp-content\/uploads\/2014\/03\/INDEX-FORMULA-EXCEL.png 752w, https:\/\/trumpexcel.com\/wp-content\/uploads\/2014\/03\/INDEX-FORMULA-EXCEL-413x300.png 413w\" sizes=\"(max-width: 450px) 100vw, 450px\" \/><\/p>\n<h3><span style=\"color: #800000;\">When to use Excel INDEX Function<\/span><\/h3>\n<p>Excel INDEX\u00a0function can be used when you want to fetch the value from a tabular data and you have the row number and column number of the data point. For example, in the example below, you can use the INDEX function to get the marks of &#8216;Tom&#8217; in Physics when you know the row number and the column number in the data set.<\/p>\n<h5><img decoding=\"async\" class=\"size-full wp-image-15056 aligncenter\" src=\"https:\/\/trumpexcel.com\/wp-content\/uploads\/2014\/03\/Excel-INDEX-Funtion-Example-1.png\" alt=\"Excel INDEX Funtion - Example 1\" width=\"474\" height=\"232\" \/><\/h5>\n<h3><span style=\"color: #800000;\">What it Returns<\/span><\/h3>\n<p>It returns the value from a table for the specified row number and column number.<\/p>\n<h3><span style=\"color: #800000;\">Syntax<\/span><\/h3>\n<p>=INDEX (array, row_num, [col_num])<br \/>\n=INDEX (array, row_num, [col_num], [area_num])<\/p>\n<p>INDEX function has 2 syntax. The first one is used in most cases, however, in case of three-way lookups, the second one is used (covered in Example 5).<\/p>\n<h3><span style=\"color: #800000;\">Input Arguments<\/span><\/h3>\n<ul>\n<li><b>array &#8211; <\/b>a<b>\u00a0<\/b>range of cells or an array constant.<\/li>\n<li><strong>row_num &#8211; <\/strong>the row number from which the value is to be fetched.<\/li>\n<li><strong>[col_num] &#8211;\u00a0<\/strong>the column\u00a0number from which the value is to be fetched. Although this is an optional argument, but if row_num is not provided, it needs to be given.<\/li>\n<li><strong>[area_num] &#8211; <\/strong>(Optional) If array argument is made up of multiple\u00a0ranges, this number would be used to select the reference from all the ranges.<\/li>\n<\/ul>\n<h3><span style=\"color: #800000;\">Additional Notes (Boring Stuff.. But Important to Know)<\/span><\/h3>\n<ul>\n<li>If the row number or the column number is 0, it returns the values of the entire row or column respectively.<\/li>\n<li>If INDEX function is used in front of a cell reference (such as A1:) it returns a cell reference instead of a value (see examples below).<\/li>\n<li>Most widely used along with the <a href=\"https:\/\/trumpexcel.com\/excel-match-function\/\">MATCH function<\/a>.<\/li>\n<li>Unlike <a href=\"https:\/\/trumpexcel.com\/excel-vlookup-function\/\">VLOOKUP<\/a>, INDEX function can return a value from the left of the lookup value.<\/li>\n<li>INDEX function have two forms &#8211; Array form and the Reference form\n<ul>\n<li>&#8216;Array form&#8217; is where you fetch a value based on row and column number from a given table.<\/li>\n<li>&#8216;Reference form&#8217; is where there are multiple tables, and you use the area_num argument to select the table and then fetch a value within it using the row and column number (see live example below).<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h2><span style=\"text-decoration: underline;\"><span style=\"color: #800000; text-decoration: underline;\">Excel INDEX Function &#8211; Examples<\/span><\/span><\/h2>\n<p>Here are six examples of using Excel INDEX Function.<\/p>\n<h3><span style=\"color: #800000;\"><strong>Example 1 &#8211; Finding Tom&#8217;s Marks in Physics (a two-way lookup)<\/strong><\/span><\/h3>\n<p>Suppose you have a dataset as shown below:<\/p>\n<p><img decoding=\"async\" class=\"size-full wp-image-15056 aligncenter\" src=\"https:\/\/trumpexcel.com\/wp-content\/uploads\/2014\/03\/Excel-INDEX-Funtion-Example-1.png\" alt=\"Excel INDEX Funtion - Example 1\" width=\"474\" height=\"232\" \/><\/p>\n<p>To find Tom&#8217;s marks in Physics, use the below formula:<\/p>\n<pre><span style=\"color: #0000ff;\">=INDEX($B$3:$E$10,3,2)<\/span><\/pre>\n<p>This INDEX formula specifies the array as $B$3:$E$10 which has the marks for all the subjects. Then it uses the row number (3) and column number (2) to fetch Tom&#8217;s marks in Physics.<\/p>\n<h3><span style=\"color: #800000;\"><strong>Example 2 &#8211;\u00a0Making the LOOKUP Value Dynamic using MATCH Function<\/strong><\/span><\/h3>\n<p>It may not always be possible to specify the row number and the column number manually. You may have a huge data set, or you may want to make it dynamic so that it automatically identifies the name and\/or subject specified in cells and give the correct result.<\/p>\n<p>Something as shown below:<\/p>\n<p><img decoding=\"async\" class=\"size-full wp-image-15057 aligncenter\" src=\"https:\/\/trumpexcel.com\/wp-content\/uploads\/2014\/03\/Excel-INDEX-Function-Example-2-Dynamic.gif\" alt=\"Excel INDEX Function - Example 2 - Dynamic\" width=\"736\" height=\"288\" \/><\/p>\n<p>This can be done using a combination of the INDEX and the <a href=\"https:\/\/trumpexcel.com\/excel-match-function\/\">MATCH<\/a> function.<\/p>\n<p>Here is the formula that will make the lookup values dynamic:<\/p>\n<pre><span style=\"color: #0000ff;\">=INDEX($B$3:$E$10,MATCH($G$5,$A$3:$A$10,0),MATCH($H$4,$B$2:$E$2,0))<\/span><\/pre>\n<p>In the above formula, instead of hard-coding the row number and the column number, MATCH function is used to make it dynamic.<\/p>\n<ul>\n<li>Dynamic Row Number is given by the following part of the formula &#8211; MATCH($G$5,$A$3:$A$10,0). It scans the name of students and identifies the lookup value ($G$5 in this case). It then returns the row number of the lookup value in the dataset. For example, if the lookup value is Matt, it&#8217;ll return 1, if it is Bob, it&#8217;ll return 2 and so on.<\/li>\n<li>Dynamic Column Number is given by the following part of the formula &#8211; MATCH($H$4,$B$2:$E$2,0). It scans the subject names and identifies the lookup value ($H$4 in this case). It then returns the column number of the lookup value in the dataset. For example, if the lookup value is Math, it&#8217;ll return 1, if it is Physics, it&#8217;ll return 2 and so on.<\/li>\n<\/ul>\n<h3><span style=\"color: #800000;\"><strong>Example 3\u00a0&#8211;\u00a0Using Drop Down Lists as Lookup Values<\/strong><\/span><\/h3>\n<p>In the above example, we have to manually enter the data. That could be time-consuming and error-prone, especially if you have a huge list of lookup values.<\/p>\n<p>A good idea in such cases is to create a drop down list of the lookup values (in this case, it could be student names and subjects) and then simply choose from the list. Based on the selection, the formula would automatically update the result.<\/p>\n<p>Something as shown below:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-15058 aligncenter\" src=\"https:\/\/trumpexcel.com\/wp-content\/uploads\/2014\/03\/Excel-INDEX-Function-Example-3-Dynamic-Drop-Downs.gif\" alt=\"Excel INDEX Function - Example 3 - Dynamic Drop Downs\" width=\"736\" height=\"288\" \/><\/p>\n<p>This makes a good dashboard component as you can have a huge data set with hundreds of students at the back end, but the end user (let\u2019s say a teacher) can quickly get the marks of a student in a subject by simply making the selections from the drop down.<\/p>\n<p><strong><span style=\"text-decoration: underline;\">How to make this:<\/span><\/strong><\/p>\n<p>The formula used in this case is the same used in Example 2.<\/p>\n<pre><span style=\"color: #0000ff;\">=INDEX($B$3:$E$10,MATCH($G$5,$A$3:$A$10,0),MATCH($H$4,$B$2:$E$2,0))<\/span><\/pre>\n<p>The lookup values have been converted into drop-down lists.<\/p>\n<p>Here are the steps to create the <a href=\"https:\/\/trumpexcel.com\/excel-drop-down-list\/\">Excel drop down list<\/a>:<\/p>\n<ul>\n<li>Select the cell in which you want the drop-down list. In this example, in G4, we want the student names.<\/li>\n<li>Go to Data \u2013&gt; Data Tools \u2013&gt; Data Validation.<\/li>\n<li>In the Data Validation Dialogue box, within the settings tab, select List from the Allow drop-down.<\/li>\n<li>In the source, select $A$3:$A$10<\/li>\n<li>Click OK.<\/li>\n<\/ul>\n<p>Now you\u2019ll have the drop-down list in cell G5. Similarly, you can create one in H4 for the subjects.<\/p>\n<h3><span style=\"color: #800000;\"><strong>Example 4 &#8211; Return Values from an Entire Row\/Column<\/strong><\/span><\/h3>\n<p>In the above examples, we&#8217;ve used Excel INDEX function to do a 2-way lookup and get a single value.<\/p>\n<p>Now, what if you want to get all the marks of a student. This can enable you to find the maximum\/minimum score of that student, or the total marks scored in all subjects.<\/p>\n<p>In simple English, you want to first get the entire row of scores for a student (let&#8217;s say Bob) and then within those values identify the highest score or the total of all the scores.<\/p>\n<p>Here is the trick.<\/p>\n<p>In Excel INDEX Function, when you enter the <strong><em>column number as 0<\/em><\/strong>, it will return the values of that entire row.<\/p>\n<p>So the formula for this would be:<\/p>\n<pre class=\"background-box\"><span style=\"color: #0000ff;\">=INDEX($B$3:$E$10,MATCH($G$5,$A$3:$A$10,0),0)<\/span><\/pre>\n<p>Now this formula. if used as is, would return the #VALUE! error. While it displays the error, in the backend, it returns an array that has all the scores for Tom &#8211;\u00a0{57,77,91,91}.<\/p>\n<p>If you select the formula in the edit mode and press F9, you&#8217;ll be able to see the array it returns (as shown below):\u00a0<img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-15060 aligncenter\" src=\"https:\/\/trumpexcel.com\/wp-content\/uploads\/2014\/03\/Excel-INDEX-Function-Example-4-Entire-Row.gif\" alt=\"Excel INDEX Function - Example 4 Entire Row\" width=\"736\" height=\"288\" \/><\/p>\n<p>Similarly, based on what the lookup value is, when the column number is specified as 0 (or is left blank), it returns all the values in the row for the lookup value<\/p>\n<p>Now to calculate the total score obtained by Tom, we can simply use the above formula within the SUM function.<\/p>\n<pre><span style=\"color: #0000ff;\">=SUM(INDEX($B$3:$E$10,MATCH($G$5,$A$3:$A$10,0),0))<\/span><\/pre>\n<p>On similar lines, to calculate the highest score, we can use MAX\/LARGE and to calculate minimum, we can use MIN\/SMALL.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-15061 aligncenter\" src=\"https:\/\/trumpexcel.com\/wp-content\/uploads\/2014\/03\/Excel-INDEX-Function-Example-4-Entire-Row-Highest-SUM.png\" alt=\"Excel INDEX Function - Example 4 Entire Row Highest SUM\" width=\"726\" height=\"223\" srcset=\"https:\/\/trumpexcel.com\/wp-content\/uploads\/2014\/03\/Excel-INDEX-Function-Example-4-Entire-Row-Highest-SUM.png 726w, https:\/\/trumpexcel.com\/wp-content\/uploads\/2014\/03\/Excel-INDEX-Function-Example-4-Entire-Row-Highest-SUM-600x184.png 600w\" sizes=\"(max-width: 726px) 100vw, 726px\" \/><\/p>\n<h3><span style=\"color: #800000;\"><strong>Example 5 &#8211;\u00a0Three Way Lookup Using INDEX\/MATCH<\/strong><\/span><\/h3>\n<p>Excel INDEX function is built to handle three-way lookups.<\/p>\n<p>What is a three-way lookup?<\/p>\n<p>In the above examples, we&#8217;ve\u00a0used one table with scores for students in different subjects. This is an example of a two-way lookup as we use two variables to fetch the score (student&#8217;s name and the subject).<\/p>\n<p>Now,\u00a0suppose in a year, a student has three different levels of exams, Unit Test, Midterm, and Final Examination (that\u2019s what I had when I was a student).<\/p>\n<p>A three-way lookup would be the ability to get a student\u2019s marks for a specified subject from the specified level of exam. This would make it a three-way lookup as there are three variables (student&#8217;s name, subject&#8217;s name, and the level of examination).<\/p>\n<p>Here is an example of a three-way lookup:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-15063 aligncenter\" src=\"https:\/\/trumpexcel.com\/wp-content\/uploads\/2014\/03\/Excel-INDEX-Function-Example-5-Three-Way-Lookup.gif\" alt=\"Excel INDEX Function - Example 5 - Three Way Lookup\" width=\"688\" height=\"500\" \/><\/p>\n<p>In the example above, apart from selecting the student&#8217;s name and subject name, you can also select the level of exam. Based on the level of exam, it returns the matching value from one of the three tables.<\/p>\n<p>Here is the formula used in cell H4:<\/p>\n<pre><span style=\"color: #0000ff;\">=INDEX(($B$3:$E$7,$B$11:$E$15,$B$19:$E$23),MATCH($G$4,$A$3:$A$7,0),MATCH($H$3,$B$2:$E$2,0),IF($H$2=\"Unit Test\",1,IF($H$2=\"Midterm\",2,3)))<\/span><\/pre>\n<p>Let&#8217;s break down this formula to understand how it works.<\/p>\n<p>This formula takes four arguments. INDEX is one of those functions in Excel that has more than one syntax.<\/p>\n<p><span style=\"color: #0000ff;\">=INDEX (array, row_num, [col_num])<\/span><br \/>\n<span style=\"color: #0000ff;\">=INDEX (array, row_num, [col_num], [area_num])<\/span><\/p>\n<p>So far in all the example above, we have used the first syntax, but to do a three-way lookup, we need to use the second syntax.<\/p>\n<p>Now let&#8217;s see each part of the formula based on the second syntax.<\/p>\n<ul>\n<li><span style=\"color: #0000ff;\">array &#8211;\u00a0($B$3:$E$7,$B$11:$E$15,$B$19:$E$23)<\/span>:\u00a0Instead of using a single array, in this case, we have used three arrays within parenthesis.<\/li>\n<li><span style=\"color: #0000ff;\">row_num &#8211; MATCH($G$4,$A$3:$A$7,0)<\/span>: MATCH function is used to find the position of the student&#8217;s name in cell $G$4 in the list of student&#8217;s name.<\/li>\n<li>col_num &#8211;\u00a0MATCH($H$3,$B$2:$E$2,0):\u00a0MATCH function is used to find the position of the subject name in cell $H$3 in the list of subject&#8217;s name.<\/li>\n<li><span style=\"color: #0000ff;\">[area_num] &#8211; IF($H$2=&#8221;Unit Test&#8221;,1,IF($H$2=&#8221;Midterm&#8221;,2,3))<\/span>: The area number value tells the INDEX function which array to select. In this example, we have three arrays in the first argument. If you select Unit Test from the drop-down, the IF function returns 1 and the INDEX functions select 1st array from the three arrays (which is $B$3:$E$7).<\/li>\n<\/ul>\n<h3><span style=\"color: #800000;\">Example 6 &#8211; Creating a Reference Using the INDEX Function (Dynamic Named Ranges)<\/span><\/h3>\n<p>This is one wild use of the Excel INDEX function.<\/p>\n<p>Let&#8217;s take a simple example.<\/p>\n<p>I have a list of names as shown below:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-15064 aligncenter\" src=\"https:\/\/trumpexcel.com\/wp-content\/uploads\/2014\/03\/Excel-Index-Function-Example-6-Reference.png\" alt=\"Excel Index Function - Example 6 - Reference\" width=\"138\" height=\"260\" \/><\/p>\n<p>Now I can use a simple INDEX function to get the last name on the list.<\/p>\n<p>Here is the formula:<\/p>\n<p><span style=\"color: #0000ff;\">=INDEX($A$2:$A$9,COUNTA($A$2:$A$9))<\/span><\/p>\n<p>This function simply counts the number of cells that are not empty and returns the last item from this list (it works only when there are no blanks in the list).<img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-15065 aligncenter\" src=\"https:\/\/trumpexcel.com\/wp-content\/uploads\/2014\/03\/Excel-INDEX-Function-Reference-2.gif\" alt=\"Excel INDEX Function - Reference 2\" width=\"300\" height=\"268\" \/><\/p>\n<p>Now, what here comes the magic.<\/p>\n<p>If you put the formula in front of a cell reference, the formula would return a cell reference of the matching value (instead of the value itself).<\/p>\n<pre><span style=\"color: #0000ff;\">=A2:INDEX($A$2:$A$9,<a style=\"color: #0000ff;\" href=\"https:\/\/trumpexcel.com\/excel-functions\/counta-function\/\" target=\"_blank\" rel=\"noopener noreferrer\">COUNTA<\/a>($A$2:$A$9))<\/span><\/pre>\n<p>You would expect the above formula to return =A2:&#8221;Josh&#8221; (where Josh is the last value in the list). However, it returns =A2:A9 and hence you get an array of names as shown below:<img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-15067 aligncenter\" src=\"https:\/\/trumpexcel.com\/wp-content\/uploads\/2014\/03\/Excel-INDEX-Functions-References-3.gif\" alt=\"Excel INDEX Functions - References 3\" width=\"424\" height=\"316\" \/><\/p>\n<p>One practical example where this technique can be helpful is in creating <a href=\"https:\/\/trumpexcel.com\/named-ranges-in-excel\/\" target=\"_blank\" rel=\"noopener noreferrer\">dynamic named ranges<\/a>.<\/p>\n<p>That\u2019s it in this tutorial. I\u2019ve tried to cover major examples of using the Excel INDEX function. If you would like to see more examples added to this list, let me know in the comments section.<\/p>\n<p>Note: I\u2019ve tried my best to proof read this tutorial, but in case you find any errors or spelling mistakes, please let me know \ud83d\ude42<\/p>\n<h2 style=\"text-align: center;\"><span style=\"text-decoration: underline;\"><span style=\"color: #800000; text-decoration: underline;\">Excel INDEX Function &#8211; Video Tutorial<\/span><\/span><\/h2>\n<p><iframe title=\"INDEX Formula in Excel - Explained with Examples\" width=\"1200\" height=\"675\" src=\"https:\/\/www.youtube.com\/embed\/XikgEUzFc3o?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen><\/iframe><\/p>\n<p><strong>Related Excel Functions:<\/strong><\/p>\n<ul>\n<li><a href=\"https:\/\/trumpexcel.com\/excel-vlookup-function\/\" target=\"_blank\" rel=\"noopener noreferrer\">Excel VLOOKUP Function<\/a>.<\/li>\n<li><a href=\"https:\/\/trumpexcel.com\/excel-hlookup-function\/\" target=\"_blank\" rel=\"noopener noreferrer\">Excel HLOOKUP Function<\/a>.<\/li>\n<li><a href=\"https:\/\/trumpexcel.com\/excel-indirect-function\/\" target=\"_blank\" rel=\"noopener noreferrer\">Excel INDIRECT Function<\/a>.<\/li>\n<li><a href=\"https:\/\/trumpexcel.com\/excel-match-function\/\" target=\"_blank\" rel=\"noopener noreferrer\">Excel MATCH Function<\/a>.<\/li>\n<li><a href=\"https:\/\/trumpexcel.com\/excel-offset-function\/\" target=\"_blank\" rel=\"noopener noreferrer\">Excel OFFSET Function<\/a>.<\/li>\n<\/ul>\n<p><span style=\"color: #800000;\"><strong>You May Also Like the Following Excel Tutorials:<\/strong><\/span><\/p>\n<ul>\n<li><a href=\"https:\/\/trumpexcel.com\/vlookup-vs-index-match\/\">VLOOKUP Vs. INDEX\/MATCH<\/a><\/li>\n<li><a href=\"https:\/\/trumpexcel.com\/index-match\/\" target=\"_blank\" rel=\"noopener noreferrer\">Excel Index Match<\/a><\/li>\n<li><a href=\"https:\/\/trumpexcel.com\/lookup-and-return-values-entire-row-column-excel\/\">Lookup and Return Values in an Entire Row\/Column<\/a>.<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Excel INDEX Function (Examples + Video) When to use Excel INDEX Function Excel INDEX\u00a0function can be used when you want to fetch the value from a tabular data and you have the row number and column number of the data point. For example, in the example below, you can use the INDEX function to get &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"Excel INDEX Function | Formula Examples + FREE Video\" class=\"read-more button\" href=\"https:\/\/trumpexcel.com\/excel-index-function\/#more-3401\" aria-label=\"Read more about Excel INDEX Function | Formula Examples + FREE Video\">Read more<\/a><\/p>\n","protected":false},"author":80,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[153],"tags":[19],"class_list":["post-3401","post","type-post","status-publish","format-standard","hentry","category-excel-functions","tag-excel-how-tos"],"_links":{"self":[{"href":"https:\/\/trumpexcel.com\/wp-json\/wp\/v2\/posts\/3401","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/trumpexcel.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/trumpexcel.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/trumpexcel.com\/wp-json\/wp\/v2\/users\/80"}],"replies":[{"embeddable":true,"href":"https:\/\/trumpexcel.com\/wp-json\/wp\/v2\/comments?post=3401"}],"version-history":[{"count":0,"href":"https:\/\/trumpexcel.com\/wp-json\/wp\/v2\/posts\/3401\/revisions"}],"wp:attachment":[{"href":"https:\/\/trumpexcel.com\/wp-json\/wp\/v2\/media?parent=3401"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/trumpexcel.com\/wp-json\/wp\/v2\/categories?post=3401"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/trumpexcel.com\/wp-json\/wp\/v2\/tags?post=3401"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}