Unfortunately, VLOOKUP, whilst powerful, simple and easy to use, is one of the least flexible functions in Excel. Just imagine for a moment that we have entered the following formula into Cell E6 (see screenshot below).
This formula is returning the value from the 2nd column (Column B) – result 21.
But, what happens when a column is inserted between Column A and Column B? The Range A2:B10 will automatically update to become A2:C10, but the lookup column number will remain the same. The value will still be returned from the 2nd column, even though that is no longer the column we wish to return the value from.
The result has now changed to 1.85, rather than 21.
Assuming we noticed, we now need to go back through each of the VLOOKUP formulas to change the 2 to a 3. Painful!
We tend to include the column number as a hard-coded number. But if we can create the column number using formulas then VLOOKUP will be able to update itself when additional columns are inserted.
Using the COLUMN formula
The COLUMN() formula will return the column number for the cell which it is referring to. Here are some examples:
This will return 7, because G is the 7th column
This will return 26, because Z is the 26th column
COLUMN only calculates based on the cell reference provided. By creating a formula using two COLUMN functions we can calculate the column number required. The format of the formula is:
=COLUMN([lookup return column])-COLUMN([first column])+1
Where [first column] and [lookup return column] are the cell references to any cell in that column. Using our initial example, it would be as follows
Try it out – this gives us a result of 2. Now we can replace the column number in our original VLOOKUP function as follows:
If any columns between Column A and Column B are inserted, our entire formula will update itself and still return the correct values.
Other advantages of using COLUMN in VLOOKUP
This method of using the COLUMN formula has one other big advantage; the formula can now be dragged, copied and moved.
By inserting the $ signs into the right places, the column number will change as the formula is copied across.
Download the Advanced VLOOKUP Cheat Sheet
Download the Advanced VLOOKUP Cheat Sheet. It includes most of the tips and tricks we’ve covered in this series, including faster calculations, multiple criteria, left lookup and much more.
Please download it and pin it up at work, you can even forward it onto your friends and co-workers.
Download the file: Advanced VLOOKUP Cheat Sheet
Other posts in the Mastering VLOOKUP Series
- How to use VLOOKUP
- VLOOKUP: What does the True/False statement do?
- VLOOKUP: How to calculate faster
- How to VLOOKUP to the left
- VLOOKUP: Change the column number automatically
- VLOOKUP with multiple criteria
- Using wildcards with VLOOKUP
- How to use VLOOKUP with columns and rows
- Automatically expand the VLOOKUP data range
- VLOOKUP: Lookup the nth item (without helper columns)
- VLOOKUP: List all the matching items
- Advanced VLOOKUP Cheat Sheet
About the author
Hey, I’m Mark, and I run Excel Off The Grid.
My parents tell me that at the age of 7 I declared I was going to become a qualified accountant. I was either psychic or had no imagination, as that is exactly what happened. However, it wasn't until I was 35 that my journey really began.
In 2015, I started a new job, for which I was regularly working after 10pm. As a result, I rarely saw my children during the week. So, I started searching for the secrets to automating Excel. I discovered that by building a small number of simple tools, I could combine them together in different ways to automate nearly all my regular tasks. This meant I could work less hours (and I got pay raises!). Today, I teach these techniques to other professionals in our training program so they too can spend less time at work (and more time with their children and doing the things they love).
Do you need help adapting this post to your needs?
I'm guessing the examples in this post don't exactly match your situation. We all use Excel differently, so it's impossible to write a post that will meet everybody's needs. By taking the time to understand the techniques and principles in this post (and elsewhere on this site), you should be able to adapt it to your needs.
But, if you're still struggling you should:
- Read other blogs, or watch YouTube videos on the same topic. You will benefit much more by discovering your own solutions.
- Ask the 'Excel Ninja' in your office. It's amazing what things other people know.
- Ask a question in a forum like Mr Excel, or the Microsoft Answers Community. Remember, the people on these forums are generally giving their time for free. So take care to craft your question, make sure it's clear and concise. List all the things you've tried, and provide screenshots, code segments and example workbooks.
- Use Excel Rescue, who are my consultancy partner. They help by providing solutions to smaller Excel problems.
Don't go yet, there is plenty more to learn on Excel Off The Grid. Check out the latest posts: