Solved

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

Posted on 2013-12-21
4
395 Views
Last Modified: 2013-12-21
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
0
Comment
Question by:nirajkrishna
  • 2
  • 2
4 Comments
 
LVL 50

Expert Comment

by:barry houdini
ID: 39733621
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
0
 

Author Comment

by:nirajkrishna
ID: 39733665
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.
0
 
LVL 50

Accepted Solution

by:
barry houdini earned 500 total points
ID: 39733704
That's exactly what my suggested formula does. If you use the first formula, i.e.

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

then you get the result 5 because the MATCH part returns 6 and you get

=VLOOKUP("ATLA",A$2:K$100,7,0)

so it returns the value from column G as required, i.e. 5

MATCH with no third argument (or 3rd argument set to 1) automatically rounds down to the previous value, so when you MATCH 3500 that matches with 3000

regards, barry
0
 

Author Closing Comment

by:nirajkrishna
ID: 39733859
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!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Some AHK commands fail in Microsoft OneNote 5 35
What is format f12.8 for a CSV file 6 41
Excel copy picture into Outlook email 7 46
min values in series 13 0
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now