Perezonomics
  • Home
  • Tesla
  • About Me

Excel Tip: Make Your VLOOKUP Double Variable

7/9/2017

 
Twice the Power!
Picture
​Anybody in business is probably pretty well acquainted with Microsoft Excel. It’s like a lump of clay just waiting to be molded and shaped into whatever you need it to be. If you work in finance, you work with Excel about as much as a truck driver grips a steering wheel. And yet, most people seem to stop exploring and learning new tools in Excel that could make them more efficient after a while. 
To the non-finance types, once they’ve learned how to do pivot tables and VLOOKUP formula’s they think that they’ve arrived. But that’s really just scratching the surface to how powerful Excel really is. So I decided to write a post on the one thing that people could add to their repertoire that would make the biggest difference. That would be doubling the power of VLOOKUP.
 
Most people who use VLOOKUPs stick to using it with only one variable. The vertical part is variable but the horizontal movement is fixed at a set number of columns.They might create a VLOOKUP to scan down a component parts list to grab the standard cost. The only variable is the item number. So the formula will look for that specific item number in a list and move over the designated number of columns to where the standard cost is.
 
But a lot of times, you may need to enter two variables. When I was working with the Cabela’s Corporation I created some complex Excel models to predict our delivery costs based on zip codes. But cost is linked to both zip code and weight. Therefore I needed two variables, distance and weight. My VLOOKUP needed to be able flex up and down based on zip code and left or right based on weight.
 
I used one VLOOKUP formula to look for the zip code and I had another VLookup formula nested within to look for the weight. This allowed the number of columns that Excel had to move to the right to be variable.
Picture
​In my example, the price is dependent on the weight. So the purple section is where the number of columns to move to the right would normally be. I created a table in Excel that had a UPS or Fedex pricing matrix based on zip codes and weight. So the VLOOKUP didn’t use a value for the number of times to move to the right. Instead it became variable.  Based on the weight it would look up the cost in my table of weights. The greater the weight, the more times it moves to the right, the more it would cost.
 
You can’t use the FALSE command if you are searching within a range so I left if off. Because if a package is between 11-15 pounds it will be the same price. So omitting the FALSE allows you to grab results by a range.
Picture
For comparisons sake, here is how that same formula would look if I only had to flex up and down for zip code but not left and right. Like if every package weighed exactly eleven pounds I could hard code the move to the fifth column.
 
=VLookup(A3,E3:J30,5,FALSE)
 
I’m oversimplifying for brevity’s sake, so you’ll need to play around with it a bit to fit your needs. When Cabela’s was evaluating cities to place distribution centers, I was able to take historical package delivery costs and price that history out of other cities and come up with a delta to actual. This allowed me to quantify how much more or less we’d spend if we shifted volume to a different city. But this can be applied to any scenario where you need to pick a value from a table.
 
Bonus Tip
Don’t you hate it when you can’t sum a column because you have errors in there caused by divide by zero errors? Use IFERROR so that you don’t end up with lots of #DIV/0! type errors. Placing IFERROR in your formula’s will rid you of the dreaded #DIV/0! forever. You just need to do the following:
 
=IFERROR(your formula,0)
 
This formula sets a default action if it encounters any kind of error. That default action is defined after the comma. In this case, I want Excel to enter a 0. But you could also type a message by using quotes or enter a cell reference.
 
So there you go. That should keep you busy for a little while and before you know it you may be vying for a spot at the World Excel Championships. 

Now available in iBooks ---> The Tesla Bubble
Picture

Comments are closed.

    Robert Perez

    Manufacturing and distribution analysis since 1993.

    Picture
    E-Mail Me

    RSS Feed

    Perezonomics is available in Apple News

    Archives

    October 2024
    September 2024
    May 2024
    April 2024
    March 2024
    February 2024
    January 2024
    December 2023
    November 2023
    October 2023
    September 2023
    August 2023
    July 2023
    June 2023
    May 2023
    April 2023
    March 2023
    February 2023
    January 2023
    December 2022
    November 2022
    October 2022
    September 2022
    August 2022
    July 2022
    June 2022
    May 2022
    April 2022
    March 2022
    February 2022
    January 2022
    December 2021
    November 2021
    October 2021
    September 2021
    August 2021
    July 2021
    June 2021
    May 2021
    April 2021
    March 2021
    February 2021
    January 2021
    December 2020
    November 2020
    October 2020
    September 2020
    August 2020
    July 2020
    June 2020
    May 2020
    April 2020
    March 2020
    February 2020
    January 2020
    December 2019
    November 2019
    October 2019
    September 2019
    August 2019
    July 2019
    June 2019
    May 2019
    April 2019
    March 2019
    February 2019
    January 2019
    December 2018
    November 2018
    October 2018
    September 2018
    August 2018
    July 2018
    June 2018
    May 2018
    April 2018
    March 2018
    February 2018
    January 2018
    December 2017
    November 2017
    October 2017
    September 2017
    August 2017
    July 2017
    June 2017
    May 2017
    April 2017
    March 2017
    February 2017
    January 2017
    December 2016
    November 2016
    October 2016
    September 2016
    August 2016
    July 2016
    June 2016
    May 2016
    April 2016
    March 2016
    February 2016
    January 2016
    December 2015
    November 2015
    October 2015
    September 2015
    August 2015
    July 2015
    June 2015
    May 2015
    April 2015
    March 2015
    February 2015
    January 2015
    December 2014
    November 2014

Web Hosting by iPage