Link to home
Start Free TrialLog in
Avatar of nirajkrishna
nirajkrishna

asked on

How to make excel use a column based on condition in vlookup

I have several columns with different prices for my location codes. I want to use a certain column's price based on the shipping amount. For example, if my amount is less than 100 I would want to use column B's price in the attached spreadsheet. If the amount is greater than 20,000 then I want to use column K. If the amount is 3,500 then I would use column G. How do I do this? I imagine it is some sort of Index Match or a conditional formula in the lookup column of the vlookup. I may have more conditions then the attached example, so I think "IF" is limited to 7 nested formulas so that wouldnt scale. Thanks in advance.
Conditional-Column-Lookup.xlsx
Avatar of barry houdini
barry houdini
Flag of United Kingdom of Great Britain and Northern Ireland image

You can use MATCH to get the column_index of a VLOOKUP, e.g. like this

=VLOOKUP("ATLA",A$2:K$300,MATCH(3500,B1:K1)+1,0)

where "ATLA" is the lookup value and 3500 the amount. Obviously you can use cell references for those values e.g. like

=VLOOKUP(M2,A$2:K$300,MATCH(N2,B1:K1)+1,0)

where M2 and N2 contain the lookup values

regards, barry
Avatar of nirajkrishna
nirajkrishna

ASKER

This is getting close, but if you notice, 3500 is not one of the columns. The columns may or may not have a pattern. I was thinking ROUNDDOWN, but if there is no pattern then I cannot really use a certain place to round down to. I need something like the max column that is still less than the weight that I specify. In your example, I would want it to "think" 3000 is the highest value that is still under 3500 so use that column.
ASKER CERTIFIED SOLUTION
Avatar of barry houdini
barry houdini
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
WHOA! You're right! I took off the +1 after your MATCH and it does work! You rock! And thanks for a pretty gosh darn simple solution!