Five Minute Lessons - Advanced
http://fiveminutelessons.com/learn-microsoft-excel/advanced
enUse the ADDRESS function to find the address of any cell
http://fiveminutelessons.com/learn-microsoft-excel/use-address-function-find-address-any-cell
<div class="field field-name-body field-type-text-with-summary field-label-hidden view-mode-rss"><div class="field-items"><div class="field-item even" property="schema:articleBody content:encoded"><p>It can sometimes be useful to know the address of a cell in a worksheet, so you can use that address in a formula. In this lesson, we'll look at how to use the ADDRESS() function to find out the address of a cell. We'll use the ADDRESS function in several examples to demonstrate how useful it can be.</p>
<h2>ADDRESS() Function Syntax</h2>
<p>The ADDRESS() function is used to find the address of a given cell. It has the following syntax:</p>
<p><strong>=ADDRESS</strong>(<strong>row_num</strong>, <strong>column_num</strong>, abs_num, a1, sheet_text)</p>
<p>The paramaters for the ADDRESS() function are as follows:</p>
<ul><li>row_num - the <strong>number</strong> of the row of the cell you want to find the address for. <strong>Required</strong>.</li>
<li>col_num - the <strong>number</strong> of the row of the cell you want to find the address for. <strong>Required</strong>.</li>
<li>abs_num - indicates whether you want to return the cell address as an absolute or relative reference. <strong>Optional</strong> but recommended. Must be between 1 and 4.</li>
<li>a1 - indicates whether you want to return the cell address in A1 format or R1C1 format. <strong>Optional. </strong>The default is A1 which is usually preferred. Must be either TRUE (A1) or FALSE (R1C1).</li>
<li>sheet_text - allows you to specify the name of another worksheet in which the ADDRESS function should look. <strong>Optional</strong>.</li>
</ul><p>Let's look at some examples where we can learn how to use these different parameters.</p>
<h2>Find the address of a cell</h2>
<p>In this simple example, we will supply the row_num and col_num values for the ADDRESS() function:</p>
<p>=ADDRESS(1,4)</p>
<p>In this example, we've asked for the address of the cell in row 1, and column 4 (cell D4). The result of this formula is shown below:</p>
<p><img alt="Use the ADDRESS function with only row and column number supplied" src="/files/excel-address-function-row-col-supplied.png" style="height:36px; width:179px" /></p>
<p>Note that the result has actually been returned as an absolute reference, $D$1. This is because we did not supply the <strong>abs_num</strong> value for the ADDRESS function, so Excel has used the default value instead. If you want to change how the cell address is calculated, you will need to supply the abs_num value as well, as shown in this example:</p>
<p><img alt="Excel's ADDRESS function, with different values for the abs_num parameter supplied." src="/files/excel-address-function-abs_num-supplied.png" style="height:36px; width:523px" /></p>
<p>As you can see, the different values of the abs_num parameter determine whether to return an absolute, mixed, or relative reference to the cell we specified. If this is a new concept for you, check out our lesson on <a href="/node/22">absolute and relative references</a> (opens in a new window).</p>
<h2>Find the address of a cell using R1C1 format</h2>
<p>Most people using Excel are familiar with referring to cells using the column letter and rown number, such as A1, B27, AA245. However, Excel offers another way to refer to cells, called R1C1 format, where you refer to cells by their Row number and Column number, such as R1C1, R27,C2, and R245C27. In my experience, it is rare to use R1C1 referencing, but it can be very useful in certain circumstances. Either way, the ADDRESS function allows you to specify which format to return the result in, as shown here:</p>
<p><img alt="Excel ADDRESS function, returning the result in A1 and R1C1 format" src="/files/excel-address-function-a1-versus-r1c1-format.png" style="height:36px; width:296px" /></p>
<p>If we combine this formula with the abs_num parameter we saw earlier, we get this result:</p>
<p><img alt="Excel ADDRESS function, using abs_num with R1C1 reference format" src="/files/excel-address-function-r1c1-abs_num.png" style="height:39px; width:637px" /></p>
<p>Note the difference between the first and second examples shown here. <strong>The first example excludes the abs_num parameter</strong>, so Excel uses the default value of 1. The other examples specify different options for abs_num, which return different versions of the cell reference using R1C1 formatting. You can compare these to the examples shown earlier using A1 referencing.</p>
<h2>Find the address of a cell in a different workbook</h2>
<p>The last parameter in the ADDRESS function allows you to specify which sheet, as well as which cell. Here are a couple of examples:</p>
<p>First, here's how to return the address of a cell in another worksheet called January in the current workbook:</p>
<p><img alt="Use Excel's ADDRESS function to find the address of a cell in another worksheet" src="/files/excel-address-function-specify-sheet-in-same-workbook.png" style="height:39px; width:297px" /></p>
<p>Second, here's how to return the address of a cell in a worksheet called January, in another workbook called Sales.xlsx:</p>
<p><img alt="Use Excel's ADDRESS function to find the address of a cell in another workbook" src="/files/excel-address-function-specify-sheet-in-different-workbook.png" style="height:36px; width:295px" /></p>
<h2>Find the address of the current cell</h2>
<p>Now that we understand how to use the ADDRESS function, let's extend it to find the address of the current cell, i.e. the cell in which we are writing our formula.</p>
<p>To do this, we'll need to figure out which row and which column the current cell is in. Excel provides the ROW() and COLUMN() functions to do just this.</p>
<p>In this example, we'll use the ROW and COLUMN functions with no parameters to return the ROW number and COLUMN number of the current cell. We'll also set the abs_num parameter to 4 so the result is a relative reference, rather than defaulting to an absolute reference:</p>
<p>=ADDRESS(ROW(),COLUMN(),4)</p>
<p><img alt="Use Excel's ADDRESS function with the ROW and COLUMN functions to find the address of the current cell" src="/files/excel-address-function-current-cell.png" /></p>
<h2>Use the ADDRESS and INDIRECT functions to find the value in another cell</h2>
<p>So far, we've looked at how to find out the address of a cell in our worksheet. Now we can look at how to use it to find out the value in that cell.</p>
<p>To do this, we need a way to write a formula that tells Excel to retrieve the value in a cell, given the address of the cell. The INDIRECT function is designed to do just that.</p>
<p>A simple example of the INDIRECT function is this formula which will return the value in cell E26. Note that as far as the INDIRECT function is concerned, "E26" is just text. The job of INDIRECT is to convert into a cell reference:</p>
<p>=INDIRECT("B26")</p>
<p>We can replace "B26" in this example with the ADDRESS function, e.g.</p>
<p>=INDIRECT(ADDRESS(26,2,4))</p>
<p>We can also use the ROW and COLUMN functions:</p>
<p>=INDIRECT(ADDRESS(ROW(B28),COLUMN(B28)))</p>
<p>Here's what these examples look like:</p>
<p><img alt="Use Excel's ADDRESS and INDEX functions to return the value from another cell" src="/files/excel-address-index-functions-return-value-from-cell.png" style="height:111px; width:277px" /></p>
<p>Of course, Formula2 and Formula3 as shown in the picture above are somewhat pointless, since we've hard coded the cell reference to B26 into the formule, which means we could replace both formulas with a simpler formula, <strong>=B26</strong>, instead. But what this formula opens up is the possibility of using other methods to calculate which row and which column to use within the ADDRESS function.</p>
<h2>Summary</h2>
<p>In this lesson, we looked at the ADDRESS function and how to use it to return the address of a cell based on row and column data that we supplied. We looked at different ways to calculate the ROW and COLUMN values to use with the ADDRESS function. We also learnt how to use the INDIRECT function to find out the value in the cell address returned by the ADDRESS function.</p>
<p>If you would like to learn more about how to use the ADDRESS function, check out this lesson on <a href="/node/209">how to find the name of the highest selling sales person in the month</a>.</p>
<p> </p>
<p> </p>
</div></div></div><section class="field field-name-taxonomy-vocabulary-3 field-type-taxonomy-term-reference field-label-inline clearfix view-mode-rss"><h2 class="field-label">Lesson Subject: </h2><ul class="field-items"><li class="field-item even"><a href="/learn-microsoft-excel/excel-formulas-and-functions" typeof="skos:Concept" property="rdfs:label skos:prefLabel" datatype="">Excel Formulas and Functions</a></li></ul></section><section class="field field-name-taxonomy-vocabulary-2 field-type-taxonomy-term-reference field-label-inline clearfix view-mode-rss"><h2 class="field-label">Level of difficulty: </h2><ul class="field-items"><li class="field-item even"><a href="/learn-microsoft-excel/advanced" typeof="skos:Concept" property="rdfs:label skos:prefLabel" datatype="">Advanced</a></li></ul></section><section class="field field-name-taxonomy-vocabulary-1 field-type-taxonomy-term-reference field-label-inline clearfix view-mode-rss"><h2 class="field-label">Software: </h2><ul class="field-items"><li class="field-item even" rel="schema:about"><a href="/learn-microsoft-excel" typeof="skos:Concept" property="rdfs:label skos:prefLabel" datatype="">Microsoft Excel</a></li></ul></section><section class="field field-name-field-learning-resource-type field-type-text field-label-inline clearfix view-mode-rss"><h2 class="field-label">Learning Resource Type: </h2><div class="field-items"><div class="field-item even" property="schema:learningResourceType">Article</div></div></section><section class="field field-name-field-time-required field-type-text field-label-inline clearfix view-mode-rss"><h2 class="field-label">Time Required: </h2><div class="field-items"><div class="field-item even" property="schema:timeRequired">PT05M</div></div></section><section class="field field-name-field-age-range field-type-text field-label-inline clearfix view-mode-rss"><h2 class="field-label">Age Range: </h2><div class="field-items"><div class="field-item even" property="schema:typicalAgeRange">18-</div></div></section><section class="field field-name-field-educational-use field-type-text field-label-inline clearfix view-mode-rss"><h2 class="field-label">Educational Use: </h2><div class="field-items"><div class="field-item even" property="schema:educationaluse">Independent Learning</div></div></section><div class="easy_social_box clearfix horizontal easy_social_lang_und">
<div class="easy_social-widget easy_social-widget-facebook first"><div class="fb-like" data-href="http://fiveminutelessons.com/learn-microsoft-excel/use-address-function-find-address-any-cell" data-send="false" data-layout="button_count" data-width="88" data-show-faces="true" data-action="like" data-colorscheme="light" data-font=""></div></div>
<div class="easy_social-widget easy_social-widget-googleplus"><div class="g-plusone" data-size="medium" data-annotation="bubble" data-href="http://fiveminutelessons.com/learn-microsoft-excel/use-address-function-find-address-any-cell"></div></div>
<div class="easy_social-widget easy_social-widget-linkedin"><script type="in/share" data-url="http://fiveminutelessons.com/learn-microsoft-excel/use-address-function-find-address-any-cell" data-counter="right"></script></div>
<div class="easy_social-widget easy_social-widget-twitter last"><a href="http://twitter.com/share" class="twitter-share-button"
data-url="http://fiveminutelessons.com/learn-microsoft-excel/use-address-function-find-address-any-cell"
data-count="horizontal"
data-lang = "en"
data-via=""
data-related=":Check it out!"
data-text="Use the ADDRESS function to find the address of any cell">Tweet</a></div>
</div> <!-- /.easy_social_box --><span rel="schema:url" resource="/learn-microsoft-excel/use-address-function-find-address-any-cell" class="rdf-meta element-hidden"></span><span property="schema:name" content="Use the ADDRESS function to find the address of any cell" class="rdf-meta element-hidden"></span>Wed, 08 Apr 2015 18:20:02 +0000millionleaves208 at http://fiveminutelessons.comhttp://fiveminutelessons.com/learn-microsoft-excel/use-address-function-find-address-any-cell#commentsFind Duplicate Rows in Excel Across Multiple Columns
http://fiveminutelessons.com/learn-microsoft-excel/find-duplicate-rows-excel-across-multiple-columns
<div class="field field-name-body field-type-text-with-summary field-label-hidden view-mode-rss"><div class="field-items"><div class="field-item even" property="schema:articleBody content:encoded"><p>Excel offers a number of ways to find rows that contain duplicate values. However, most of them focus on finding rows where the value in just one column is duplicated. In this lesson, we look at how to use the COUNTIFS function to find rows with duplicate entries in two or more columns. We then use the COUNTIFS function in combination with Excel's Conditional Formatting feature to highlight duplicate and triplicate rows.</p>
<h2>Finding Duplicate Rows - Example data</h2>
<p>This lesson uses an example of a product order table. Our data table lists orders of spare parts for several computers. We need to identify how often each spare part is being ordered for each machine. A sample of this data can be seen in the following picture:</p>
<p><img alt="Excel - find duplicate rows, sample data for lesson" src="/files/excel-duplicate-rows-lesson-sample-data.png" style="border-style:solid; border-width:1px; height:274px; width:343px" /></p>
<p>As you can see in this example, there are several examples where the <strong>Product </strong>and <strong>Part Ordered</strong> are repeated. For example, a Desktop Monitor has been ordered twice, as have Backup Tapes for the Server.</p>
<h2>The COUNTIFS syntax</h2>
<p>COUNTIFS is a function that allows you to count only those rows in a spreadsheet where certain criteria are met. It is closely related to the COUNTIF function. COUNTIF allows you to use just one criteria, whereas COUNTIFS allows you to use multiple criteria. You can find out more about COUNTIF in our lesson on how to <a href="/node/109">Use COUNTIF to count the cells in a range that match certain values</a>. Note that the COUNTIFS function was introduced in Excel 2007, so the method we're going to look at in this lesson will only work if you have Excel 2007, Excel 2010 or Excel 2013. The screenshots and examples in this lesson have been produced using Excel 2013, but this method will work in all three versions.</p>
<p>COUNTIFS has the following syntax:</p>
<p>=COUNTIFS(criteria_range1, criteria1, [criteria_range2, criteria2]…)</p>
<p>As shown here, you can define multiple ranges that the COUNTIFS function should look at, and the criteria it should use when deciding whether to count each row as part of its calculation. Our example will require that we use two range/criteria pairs, but Excel allows you to have up to 127 pairs in a single formula.</p>
<h2>Use COUNTIFS to find rows that contain duplicate values</h2>
<p>The first step in identifying duplicate rows is to write a formula using COUNTIFS to count how often each row is repeated.</p>
<p>We'll start by adding a new column to our table, into which we will enter this formula.</p>
<p>The formula we will use is:</p>
<p><strong>=COUNTIFS(B:B,B2,C:C,C2)</strong></p>
<p>This to be entered into D2 in our table and then copied and pasted down the table. The results of this are shown here:</p>
<p><img alt="Excel finding duplicate rows in a table, showing duplicate count column" src="/files/excel-duplicate-rows-sample-data-with-duplicates-counted.png" style="border-style:solid; border-width:1px; height:275px; width:429px" /></p>
<p>As you can see, there are four rows shown here where the Duplicate value is greater than one. If you look more closely, you'll see that there are actually only two rows which are duplicated (Desktop | Monitor, and Server | Backup Tapes). This indicates that our formula is working, since it has found each row which has a duplicate somewhere in the table.</p>
<p>Let's look a little more closely at the formula we've used:</p>
<p><strong>=COUNTIFS(B:B,B2,C:C,C2)</strong></p>
<ul><li>Note how we've used B:B to represent the Product column, rather than B2:B13. By doing this, we ensure that our formula will work no matter how many rows we add to the table. We've done the same with C:C to represent the Part Ordered column.</li>
<li>We've used B2 and C2 to identify the criteria for the COUNTIFS function. Note that they are relative references, so sopying this formula from D2 to the rows below it ensures that the COUNTIFS function always uses the values in the current row as its criteria.</li>
<li>The COUNTIFS function will only count rows in which both of our criteria are matched.</li>
<li>Note that if you just wanted to count the rows where only the Product appears multiple times, you would use COUNTIF instead, like this:
<ul><li>=COUNTIF(B:B,B2)</li>
</ul></li>
<li>This version of the COUNTIFS formula allows you to only show a value in the Duplicates column if the row is a duplicate - in rows that only appear once, nothing will appear in the Duplicates column:
<ul><li>=IF(COUNTIFS(B:B,B2,C:C,C2)>1,COUNTIFS(B:B,B2,C:C,C2),"") or, even simpler, try this:</li>
<li>=IF(COUNTIFS(B:B,B2,C:C,C2)>1,"Duplicate,"")</li>
</ul></li>
</ul><p>At this point, you may consider your task complete - we've identified the duplicate rows, and we can now use this information to analyse our data further.</p>
<h2>Use COUNTIFS to apply Conditional Formatting</h2>
<p>However, it may be that we don't want to add another column to identify the duplicates - we only want to <em>identify </em>those rows which are duplicates. We can do this using the COUNTIFS function in combination with Excel's Conditional Formatting feature:</p>
<ul><li><strong>Click on cell A1</strong>. This is important - if you don't, then the Conditional Formatting we are about to set up may be applied to the wrong cells.</li>
<li>Create a new Conditional Formatting rule using the Conditional Formatting button on the Home ribbon toolbar:<br /><img alt="Excel Conditional Formatting menu to create a new rule" src="/files/excel-conditional-formatting-menu-new-rule-highlighted.png" style="height:348px; width:180px" /></li>
<li>In the New Rule dialog box, change the values to look like the following:<br /><img alt="Excel Conditional Formatting, new formatting rule dialog box with formula for checking duplicate rows" src="/files/excel-conditional-formatting-new-rule-highlight-duplicate-rows.png" style="height:437px; width:459px" /></li>
<li>There are several points to note when creating the new rule:
<ul><li>We are using the option to <strong>Use a formula to determine which cells to format.</strong> Although Excel offers a Conditional Formatting option to highlight duplicate cells, it won't help us in this scenario.</li>
<li>The formula that you need to enter in the <strong>Rule Description</strong> (<strong>Format values where this formula is true</strong>) is a version of the formula we used in the previous section, but it's critical that you copy it as it's shown here, =COUNTIFS($B:$B,$B1,$C:$C,$C1)>1, otherwise you may get unpredictable results. The $ signs to make the references absolute are needed, as is the change of B2 and C2 in our original formula to $B1 and $C2.</li>
<li>You can choose whatever formatting you want to appy - I've chosen to fill cells with green shading.</li>
</ul></li>
<li>Once you click OK to this rule, you will need to edit it further to define which cells it should be applied to. You can access the <strong>Manage Rules</strong> dialog box using the <strong>Conditional Formatting</strong> menu as shown above (it's the last item in the menu).<br /><img alt="Excel Conditional Formatting Rules Manager, duplicate rows highlighting rule" src="/files/excel-conditional-formatting-conditional-formatting-rules-manager.png" style="height:274px; width:600px" /></li>
<li>You should then see the rule you just created in the list - if you don't, change the option shown above from <strong>Current Selection</strong> to <strong>This Workbook</strong> and it should appear.</li>
<li>Change the <strong>Applies to</strong> value from what is shown above, =$A$2 to =$A:$D. This will tell Excel we want to apply this rule to all cells in columns A through to D.
<ul><li>You can either type this formula in, or you can click and drag across the row headings to select the rows you want.</li>
<li>You could also select a specific range of cells, although that will mean you may need to edit this range again in the future.</li>
</ul></li>
<li>You can then click Apply to see a preview of the rule changes in your spreadsheet, or you can click OK to save the changes and return to your spreadsheet, which should now look like this:<br /><img alt="Excel, duplicate rows highlighted with Conditional Formatting using a COUNTIFS formula to determine which rows are duplicates" src="/files/excel-duplicate-rows-highlighted-conditional-formatting.png" style="border-style:solid; border-width:1px; height:278px; width:425px" /></li>
<li>If your spreadsheet looks like this instead, you probably missed the first step in the instructions, which was to click on A1 before creating the rule. In that case, you might see something like this:<br /><img alt="Excel duplicate rows conditional formatting applied in the wrong place" src="/files/excel-duplicate-rows-conditional-formatting-highlighting-wrong.png" style="border-style:solid; border-width:1px; height:313px; width:428px" /></li>
<li>As you can see, the formatting has been applied to the wrong rows. If this happens, then return to the <strong>Conditional Formatting Rules Manager</strong> as show above, and edit the rule. You will see something like this:<br /><img alt="Excel duplicate rows conditional highlighting formula wrong" src="/files/excel-duplicate-rows-conditional-formatting-formula-wrong.png" style="height:438px; width:458px" /></li>
<li>Note how the formula we entered has changed (you might see a different formula, but the key is that the criteria values for both ranges have changed). If you see this, it is because you did not have cell A1 selected when creating the rule.To fix this, you can:
<ul><li>Delete and start the rule, making sure you select A1 before starting.</li>
<li>Change the formula back to what it should be.</li>
</ul></li>
</ul><h2>Extending your conditional formatting rules to highlight triplicates and more</h2>
<p>In the example above, we created a conditional formatting rule to highlight any rows that are duplicates of other rows, based on a combination of the Product and Part Number fields. You could extend this to cover additional duplicate rule checks - and it's easy to do. To highlight rows that appear three times sor more, do the following:</p>
<ul><li>Create a new rule using the steps in the previous section. Make it the same as the rule in the example above, with one change to the formula:
<ul><li>=COUNTIFS($B:$B,$B1,$C:$C,$C1)>=3</li>
<li>Don't forget to change the formatting you apply to rows that appear three times or more or you won't see any difference.</li>
</ul></li>
<li>Then, change the order of the rules in the Conditional Formatting Rules Manager, like this:<br /><img alt="Excel finding duplicate rows with Conditional Formatting, multiple rules" src="/files/excel-duplicate-rows-multiple-conditional-formatting-rules.png" style="height:274px; width:600px" /></li>
<li>There are two key points to note here:
<ul><li>The sequence of the rules can matter. In this case, the triplicate checking rule appears before the duplicate checking rule. If you are trying to create multiple rules to apply to the same range of cells and the formatting is not being applied correctly, it is worth experimenting with the sequence of the rules (there are buttons to move rules up and down next to the <strong>Delete Rule</strong> button.</li>
<li>The option to <strong>Stop if True</strong> can help solve problems in certain cases, if the second and subsequent rules are changing the formatting applied in an earlier rule. This means that the subsequent rules will not be run once the conditions of the first rule have been met.</li>
</ul></li>
<li>Here's how the spreadsheet we've been working with looks when you have both rules applied (I have tweaked the data from the original example to include Server | Backup Tapes a third time):<br /><img alt="Excel duplicate checking, multiple conditional formatting rules applied" src="/files/excel-duplicate-rows-multiple-conditional-formatting-rules-applied.png" style="height:274px; width:427px" /></li>
<li>As a final thought, you could also apply Excel's Autofilter tool to this table. Autofilter allows you to filter based on the colours in a cell, so you could filter out just the green or blue rows. Read our lesson on <a href="/node/20">How to use Autofilter in Excel</a>.</li>
</ul><h2>Checking for Duplicate Rows using COUNTIFS - Lesson Summary</h2>
<p>In this lesson, we looked at two ways to identify duplicate rows in a spreadsheet, where a row should only be considered a duplicate if the values in two cells match (rather than just one value).</p>
<p>The COUNTIFS function, available in all versions of Excel since 2007, allows us to check for a match of more than one value across all the rows in our table. Unfortunately, it also requires that you create a new column in your table in which to put the COUNTIFS formula; this formula needs to be in every row of your table.</p>
<p>Conditional Formatting lets us take the COUNTIFS function we looked at and use it to apply formatting to rows that are duplicates or even triplicates. We can do this without having to create a new column in our table (note that while we left the Duplicate column in our examples above, we didn't need it there for the Conditional Formatting part of the lesson.</p>
<h3>Finally, if you have any questions or feedback on this lesson, please leave a comment below.</h3>
</div></div></div><section class="field field-name-taxonomy-vocabulary-2 field-type-taxonomy-term-reference field-label-inline clearfix view-mode-rss"><h2 class="field-label">Level of difficulty: </h2><ul class="field-items"><li class="field-item even"><a href="/learn-microsoft-excel/advanced" typeof="skos:Concept" property="rdfs:label skos:prefLabel" datatype="">Advanced</a></li></ul></section><section class="field field-name-taxonomy-vocabulary-1 field-type-taxonomy-term-reference field-label-inline clearfix view-mode-rss"><h2 class="field-label">Software: </h2><ul class="field-items"><li class="field-item even" rel="schema:about"><a href="/learn-microsoft-excel" typeof="skos:Concept" property="rdfs:label skos:prefLabel" datatype="">Microsoft Excel</a></li></ul></section><section class="field field-name-field-learning-resource-type field-type-text field-label-inline clearfix view-mode-rss"><h2 class="field-label">Learning Resource Type: </h2><div class="field-items"><div class="field-item even" property="schema:learningResourceType">Article</div></div></section><section class="field field-name-field-time-required field-type-text field-label-inline clearfix view-mode-rss"><h2 class="field-label">Time Required: </h2><div class="field-items"><div class="field-item even" property="schema:timeRequired">PT05M</div></div></section><section class="field field-name-field-age-range field-type-text field-label-inline clearfix view-mode-rss"><h2 class="field-label">Age Range: </h2><div class="field-items"><div class="field-item even" property="schema:typicalAgeRange">18-</div></div></section><section class="field field-name-field-educational-use field-type-text field-label-inline clearfix view-mode-rss"><h2 class="field-label">Educational Use: </h2><div class="field-items"><div class="field-item even" property="schema:educationaluse">Independent Learning</div></div></section><div class="easy_social_box clearfix horizontal easy_social_lang_und">
<div class="easy_social-widget easy_social-widget-facebook first"><div class="fb-like" data-href="http://fiveminutelessons.com/learn-microsoft-excel/find-duplicate-rows-excel-across-multiple-columns" data-send="false" data-layout="button_count" data-width="88" data-show-faces="true" data-action="like" data-colorscheme="light" data-font=""></div></div>
<div class="easy_social-widget easy_social-widget-googleplus"><div class="g-plusone" data-size="medium" data-annotation="bubble" data-href="http://fiveminutelessons.com/learn-microsoft-excel/find-duplicate-rows-excel-across-multiple-columns"></div></div>
<div class="easy_social-widget easy_social-widget-linkedin"><script type="in/share" data-url="http://fiveminutelessons.com/learn-microsoft-excel/find-duplicate-rows-excel-across-multiple-columns" data-counter="right"></script></div>
<div class="easy_social-widget easy_social-widget-twitter last"><a href="http://twitter.com/share" class="twitter-share-button"
data-url="http://fiveminutelessons.com/learn-microsoft-excel/find-duplicate-rows-excel-across-multiple-columns"
data-count="horizontal"
data-lang = "en"
data-via=""
data-related=":Check it out!"
data-text="Find Duplicate Rows in Excel Across Multiple Columns">Tweet</a></div>
</div> <!-- /.easy_social_box --><span rel="schema:url" resource="/learn-microsoft-excel/find-duplicate-rows-excel-across-multiple-columns" class="rdf-meta element-hidden"></span><span property="schema:name" content="Find Duplicate Rows in Excel Across Multiple Columns" class="rdf-meta element-hidden"></span>Wed, 18 Jun 2014 18:30:34 +0000millionleaves199 at http://fiveminutelessons.comhttp://fiveminutelessons.com/learn-microsoft-excel/find-duplicate-rows-excel-across-multiple-columns#commentsUse INDEX to lookup multiple values in a list
http://fiveminutelessons.com/learn-microsoft-excel/use-index-lookup-multiple-values-list
<div class="field field-name-body field-type-text-with-summary field-label-hidden view-mode-rss"><div class="field-items"><div class="field-item even" property="schema:articleBody content:encoded"><p>Excel's VLOOKUP function is excellent when you want to find a value in a table based on a lookup value. But if your table includes your lookup value multiple times, you'll find that VLOOKUP can't do it. This lesson shows you how to use the INDEX function (plus some other functions) to find all matching values in a list, and return a value from another column in the same row. It also looks at how to do this when you want to return all values which are a partial match (i.e. a wildcard search) to the values in your lookup table.</p>
<p>Here's a simple example based on a question I was asked by one of our readers.</p>
<ul><li>There are two worksheets, one containing Form data for a mail merge, and one containing Parcel data, some of which is to be included in the mail merge.</li>
<li>The Form worksheet includes a row for each landowner who is to receive a letter. One of the columns in the spreadsheet is an ID for each landowner.</li>
<li>The Parcel worksheet contains data about land parcels owned by the landowners in the Form worksheet.</li>
<li>The mail merge will generate a letter to all land owners. That letter should include details of all of the land parcels owned by that individual land owner.</li>
</ul><p>In this lesson I'm going to focus on how to include that land parcel information in the mail merge, but I'm not going to discuss how to set up the mail merge with Microsoft Word.</p>
<h2>Use the Index function to return multiple values a list</h2>
<p>Let's say our Parcel worksheet looks like this:</p>
<p><img alt="Excel INDEX function to find multiple instances of a value, sample data table" src="/files/Excel-INDEX-multiple-lookups-data-example.png" style="height:110px; width:229px" /></p>
<p>As you can see, John Smith (ID H240) appears three times. We want to include a list of the crops John grows in our mail merge letter. If you've used a VLOOKUP function before, you'll know that we can use it to find the first crop for John in the list, but not the second or third.</p>
<h3>Find all the row numbers to match our lookup value</h3>
<p>Let's start solving our problem by first finding the row number of each row in which H240 appears, by using the formula below. After that we'll then extend this formula to find the crop value in each row:</p>
<p>{=SMALL(IF($A$2:$A$6=$A$9,ROW($A$2:$A$6)),ROW(1:1))}</p>
<p>Here is a breakdown of this formula:</p>
<ul><li><a id="array" name="array">The { } around the formula indicates that this is an <strong>array</strong> formula.</a>
<ul><li>Note that you <strong>don't type these braces</strong> as part of the formula. You have to press <strong>Ctrl+Shift+Enter</strong> key when entering the formula to tell Excel it is an array formula, after which the { } will automatically appear. If you don't, our formula will return a #VALUE error.</li>
<li>If you're using Excel for Mac, you'll need to press <strong>CMD+SHIFT+Enter</strong> instead.</li>
</ul></li>
<li>The SMALL function has the syntax SMALL(array,k).
<ul><li>It looks up a list and finds the k'th smallest value in the array.</li>
<li>If k = 1 it will find the smallest. If k=2 it will find the second smallest value, and so on.</li>
<li>The second instance of the ROW function is used to find k in our formula. In this example, ROW will return the row number of row 1, which is, of course, 1.</li>
</ul></li>
<li>The IF function looks to see if the value in A9 is in the list.
<ul><li>In our example, A9 is where we'll enter H240 as our lookup value.</li>
<li>Note that the IF function will only return a value if our number is in the list.</li>
<li>If not, it will return a null value, which will cause the SMALL function to generate an error. We'll look at how to hide that error later.</li>
</ul></li>
<li>The ROW function is used twice:
<ul><li>If the IF function finds our value in the list, the ROW function returns the row number in which it was found. Note that it returns the row number of the worksheet, not the row number inside our table. This will be important later.</li>
<li>As noted above, the ROW function is also used in our formula to return k. </li>
</ul></li>
</ul><p>The screenshot below shows this formula in action: </p>
<p><img alt="Excel using the INDEX function to find multiple lookup values in a list" src="/files/Excel-INDEX-multiple-lookups-find-row-numbers.png" style="height:232px; width:283px" /></p>
<p>In the screenshot above, I've entered h240 into A9 (you'll note that our formula isn't case sensitive). I've then entered the formula above into A11 as an array formula (don't forget that part!). It has returned 2, which is the row number for the first instance of H240 in the list. After that, I've copied and pasted the formula into rows A12 to A13. The formula has automatically picked up the correct row numbers, and generated an error when it couldn't find a fourth value.</p>
<p>However, there has been some magic under the hood that you can't see here. When I copied and pasted the formula into the additional rows, the array formula changed. Here are the formulas in each cell:</p>
<p>{=SMALL(IF($A$2:$A$6=$A$9,ROW($A$2:$A$6)),ROW(1:1))}<br />
{=SMALL(IF($A$2:$A$6=$A$9,ROW($A$2:$A$6)),ROW(2:2))}<br />
{=SMALL(IF($A$2:$A$6=$A$9,ROW($A$2:$A$6)),ROW(3:3))}<br />
{=SMALL(IF($A$2:$A$6=$A$9,ROW($A$2:$A$6)),ROW(4:4))} </p>
<p>Note how the ROW parameters in each formula are different: 1:1, 2:2, 3:3, 4:4. This is telling the SMALL function to find the 1st, 2nd, 3rd and 4th values in the list that match our lookup value. As I said, you don't need to edit the formula yourself - it updates itself when you copy and paste it.</p>
<h3>Use the INDEX function to find the Crop values</h3>
<p>Now that we know the row numbers for each instance of H240 in our example, we can use the INDEX function to use the row number in order to obtain the Crop value. If you're not familiar with the INDEX function, you can <a href="/node/140" target="_blank">read our lesson on INDEX here</a> (it will open in a new tab).</p>
<p>Here's the adjusted formula:</p>
<p>{=INDEX($A$2:$C$7,SMALL(IF($A$2:$A$7=$A$9,ROW($A$2:$A$7)),ROW(1:1))-1,3)}</p>
<p>Here's how this function breaks down:</p>
<ul><li>The INDEX function looks in our table ($A$2:$B$7)</li>
<li>It then uses the SMALL function to find which row to look in and then subtracts 1 from what SMALL tells us.
<ul><li>Remember that the ROW function returns the row in the worksheet where our value was found.</li>
<li>The INDEX function considers the first row of our table as row 1. Because our table data starts in row 2, we need to subtract 1 from the ROW value to get the correct row inside the table.</li>
<li>If you're applying this solution to your own spreadsheet, you may need to adjust this value to take account of where your data table is located.</li>
</ul></li>
<li>The INDEX function then looks in column 3, which is where the crop data is found.</li>
</ul><p>Here's how our spreadsheet looks now.</p>
<p><img alt="Excel INDEX function find values in a table" src="/files/Excel-INDEX-multiple-lookups-find-crop-values.png" style="height:230px; width:284px" /></p>
<h3>Hide errors generated by our formula</h3>
<p>At this point, we've done what we set out to do, which was find all of the crops related to John Smith. However, if we are going to use this solution in a mail merge, we don't want the mail merge to print #NUM in our letters. Let's finish off this lesson by looking at how you can hide error values when they occur in our formula:</p>
<p>{=IF(ISERROR(INDEX($A$2:$C$7,SMALL(IF($A$2:$A$7=$A$9,ROW($A$2:$A$7)),ROW(1:1))-1,3)),"",INDEX($A$2:$C$7,SMALL(IF($A$2:$A$7=$A$9,ROW($A$2:$A$7)),ROW(1:1))-1,3))}</p>
<p>This formula looks terrifying, but it's actually very simple.</p>
<ul><li>The IF function tests to see if our formula generates an error. It does this by using the ISERROR function.</li>
<li>If the ISERROR function is true (i.e. our formula generates an error) then the IF function returns "", which means the cell containing our formula will appear to be blank.</li>
<li>If the ISRROR function is not true, then our formula works OK, and the IF function will use it to return the correct value.</li>
</ul><p>There's not much to see when we use this version of the formula, but here is what our spreadsheet looks like now:</p>
<p><img alt="Use Excel's ISERROR function to hide formula errors in a spreadsheet" src="/files/Excel-INDEX-multiple-lookups-ISERROR-hide-errors_0.png" style="height:186px; width:306px" /></p>
<h2>Finding all matching values using partial match</h2>
<p>A couple of people have asked in the comments below whether there was a way to use a wildcard, or partial match, for the lookup value in A9. The answer is yes - and here's the formula to use - you can replace the array formula in A11:A14 in the example above:</p>
<p>=IF(ISERROR(SMALL(IF(IF(ISERROR(SEARCH($A$9,$A$1:$A$7)),FALSE,TRUE),ROW($A$1:$A$7)),ROW($C$1:$C$7))),"",INDEX($A$1:$C$7,SMALL(IF(IF(ISERROR(SEARCH($A$9,$A$1:$A$7)),FALSE,TRUE),ROW($A$1:$A$7)),ROW($C$1:$C$7)),3))</p>
<p><img alt="Excel - using the index function to find matching values with partial match" src="/files/excel-index-multiple-lookups-partial-match.png" style="width: 355px; height: 283px;" /></p>
<p>This formula uses the SEARCH function to determine if the lookup value in row 9 can be found in the cells in A10. In practical terms, this formula allows you to type a partial match, e.g. H24, and the formula will return all instances where H24 is found in column A. Note that you don't need to use asterisks, *, to indicate to Excel that you are using a wildcard - you simply type the partial string you want to match.</p>
<p><strong>Note that there is a twist in this final example</strong>. You can't copy and paste the formula from A11 into A12 - A14 as you could in earlier examples. You have to do the following:</p>
<ul><li>Get the array formula working in A11, and returning the correct result (Beans in my example).</li>
<li>Select all the cells where you want this formula to be (including the cell with the first working example). In my example it is A11:A14. Make sure the active cell is the one containing the formula.</li>
<li>Click in the formula bar to start editing the formula but <strong>don't change anything</strong>.</li>
<li>Press the keys to enter an array formula (CTRL+Shift+ENTER on PC or Command+Shift+Enter on Mac).</li>
<li>The selected cells will change to show you the correct results, and the selected cells will become an array.</li>
</ul><p>Once you do this, the selected cells can only be treated together as an array. If you try to edit, say, A13, you'll get an alert telling you that you can't edit an array. If you want to change your formula, you need to select all of the cells in the array, click in the formula bar, and then press the keys to re-enter the formula as an array formula. If you simply want to break the array, select all of the cells, click in the formula bar and press Enter.</p>
<h2>Summary</h2>
<p>And with that, we're finished. If you have any questions about this solution, please let us know in the comments!</p>
<p>* This lesson was inspired by a post by Ashish Mathur for Excel 2003. <a href="http://office.microsoft.com/en-us/excel-help/how-to-look-up-a-value-in-a-list-and-return-multiple-corresponding-values-HA001226038.aspx#_Toc273640147" target="_blank">You can read that post here</a>. The inspiration for this lesson came from a question from one of our readers on the original <a href="/node/140#comment-414" target="_blank">lesson on how to use the INDEX function.</a> The formula for using a wildcard came from <a href="http://forums.techguy.org/business-applications/731243-excel-how-use-wildcards-array.html" target="_blank">this forum discussion</a>. All links open in a new tab.</p>
</div></div></div><section class="field field-name-taxonomy-vocabulary-2 field-type-taxonomy-term-reference field-label-inline clearfix view-mode-rss"><h2 class="field-label">Level of difficulty: </h2><ul class="field-items"><li class="field-item even"><a href="/learn-microsoft-excel/advanced" typeof="skos:Concept" property="rdfs:label skos:prefLabel" datatype="">Advanced</a></li></ul></section><section class="field field-name-taxonomy-vocabulary-1 field-type-taxonomy-term-reference field-label-inline clearfix view-mode-rss"><h2 class="field-label">Software: </h2><ul class="field-items"><li class="field-item even" rel="schema:about"><a href="/learn-microsoft-excel" typeof="skos:Concept" property="rdfs:label skos:prefLabel" datatype="">Microsoft Excel</a></li></ul></section><section class="field field-name-field-learning-resource-type field-type-text field-label-inline clearfix view-mode-rss"><h2 class="field-label">Learning Resource Type: </h2><div class="field-items"><div class="field-item even" property="schema:learningResourceType">Article</div></div></section><section class="field field-name-field-time-required field-type-text field-label-inline clearfix view-mode-rss"><h2 class="field-label">Time Required: </h2><div class="field-items"><div class="field-item even" property="schema:timeRequired">PT05M</div></div></section><section class="field field-name-field-age-range field-type-text field-label-inline clearfix view-mode-rss"><h2 class="field-label">Age Range: </h2><div class="field-items"><div class="field-item even" property="schema:typicalAgeRange">18-</div></div></section><section class="field field-name-field-educational-use field-type-text field-label-inline clearfix view-mode-rss"><h2 class="field-label">Educational Use: </h2><div class="field-items"><div class="field-item even" property="schema:educationaluse">Independent Learning</div></div></section><div class="easy_social_box clearfix horizontal easy_social_lang_und">
<div class="easy_social-widget easy_social-widget-facebook first"><div class="fb-like" data-href="http://fiveminutelessons.com/learn-microsoft-excel/use-index-lookup-multiple-values-list" data-send="false" data-layout="button_count" data-width="88" data-show-faces="true" data-action="like" data-colorscheme="light" data-font=""></div></div>
<div class="easy_social-widget easy_social-widget-googleplus"><div class="g-plusone" data-size="medium" data-annotation="bubble" data-href="http://fiveminutelessons.com/learn-microsoft-excel/use-index-lookup-multiple-values-list"></div></div>
<div class="easy_social-widget easy_social-widget-linkedin"><script type="in/share" data-url="http://fiveminutelessons.com/learn-microsoft-excel/use-index-lookup-multiple-values-list" data-counter="right"></script></div>
<div class="easy_social-widget easy_social-widget-twitter last"><a href="http://twitter.com/share" class="twitter-share-button"
data-url="http://fiveminutelessons.com/learn-microsoft-excel/use-index-lookup-multiple-values-list"
data-count="horizontal"
data-lang = "en"
data-via=""
data-related=":Check it out!"
data-text="Use INDEX to lookup multiple values in a list">Tweet</a></div>
</div> <!-- /.easy_social_box --><span rel="schema:url" resource="/learn-microsoft-excel/use-index-lookup-multiple-values-list" class="rdf-meta element-hidden"></span><span property="schema:name" content="Use INDEX to lookup multiple values in a list" class="rdf-meta element-hidden"></span>Fri, 11 Oct 2013 17:47:42 +0000millionleaves143 at http://fiveminutelessons.comhttp://fiveminutelessons.com/learn-microsoft-excel/use-index-lookup-multiple-values-list#comments