# Excel and Lookup Functions. How to Find the nth Occurrence

### | | Information Helpful? Why Not Donate.

Current Special! Complete Excel Excel Training Course for Excel 97 - Excel 2003, only \$145.00. \$59.95 Instant Buy/Download, 30 Day Money Back Guarantee & Free Excel Help for LIFE!

Got any Excel Questions? Free Excel Help

Microsoft Excel has a very rich selection of Lookup & Reference Functions. These can be used on a Table of data to extract out details corresponding to a specified value. Perhaps the most popular of these Excel functions is the VLOOKUP Formula .

If we combine (Nesting) Lookup functions together we can do some pretty clever stuff, but unfortunately Excel has no function that will return the nth occurrence of our specified data. There is however a very simple method we can use to find any specified occurrence we like.

Assume we have a two column table of data, with Column A housing first names and Column B their corresponding ages. We can easily use a VLOOKUP Formula to extract out a persons age based on their name. The trouble is there is more the one occurrence of some names. We do not want to lookup the name Dave and have the VLOOKUP Formula find the first occurrence, but the 2nd, 3rd or whatever. Here is how we can do this.  Remember this example is based on the data being in Column A and B.

First select all of Column A by clicking the letter A, then go to Insert>Columns, now Starting from cell A2 (B1 is a heading) enter this formula:

=B2&COUNTIF(\$B\$2:B2,B2)

Now copy this down as many rows as you have data in Column B. You will end up with names like: Dave1, Dave2, Dave3 etc.  If you haven't guessed already, we can now use Column A as the column to find the nth occurrence of any name. If the Lookup function we were using is the VLOOKUP, then the formula below will return the age for the 3rd occurrence of the name Dave.

=VLOOKUP("Dave3",\$A\$1:\$C\$100,3,FALSE)

You can of course hide Column A from view as we do not need to see it. You can even use the names in Column A as the Source range for a list in another cell by going to Data>Validation -List Then reference the cell housing this list in your VLOOKUP

Excel Dashboard Reports & Excel Dashboard Charts 50% Off Become an ExcelUser Affiliate & Earn Money

Special! Free Choice of Complete Excel Training Course OR Excel Add-ins Collection on all purchases totaling over \$64.00. ALL purchases totaling over \$150.00 gets you BOTH! Purchases MUST be made via this site. Send payment proof to [email protected] 31 days after purchase date.