If statement inside vlookup? I don't know

AdRock

Board Regular
Joined
Apr 1, 2011
Messages
128
I have 2 spreadsheets.

The first spreasheet (spreadsheet 1) in column A, is a list of post code areas (NW, SO, IP etc). There are 3 other columns each with different numbers (costs) for that postcode area.

In the other spreadsheet (spreadsheet 2) I have a list of orders. Each order has a postcode area and a quantity and a cost (which i need to calculate).

What I need to do is look up each of the postcode areas and the quantities in spreadsheet 2 and possible do a vlookup (or whatever i need) on spreadsheet 1 so i can find the cost.

I know i can do a vlookup to find the postcode area and return a value but how i choose the right cost for the given quantity?

example: it should look for PL in spreadsheet 1 and find 20 as the cost and for the other order it should find 25

Spreadsheet 2 order

P/Code Qty Cost
PL 1 ?
PL 2 ?

Spreadsheet 1
P/Code 1 2 3
PL 20 25 30

I haven't got a clue how i choose which column to look in so any help appreciated.

I hoe i have explained it well enough
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
What is your determining factor in choosing which of the 3 columns of cost is chosen for a postcode?
 
Upvote 0
I'm not entirely sure, but I think that if the quantity is 1 item, then it should charge 20 from looking at the spreadsheet 1 layout, if 2 items, 25, 3 items, 30 etc?
 
Upvote 0
I'm not entirely sure, but I think that if the quantity is 1 item, then it should charge 20 from looking at the spreadsheet 1 layout, if 2 items, 25, 3 items, 30 etc?


Yes... that is exaclty right.

I need to lookup the postcode and get a cost for the qty, so if its quantity is 1 it returns 20
 
Upvote 0
Sheet1
Your lookup Table is in A1:D10


Sheet2
PL in A1
1 In B1

Your formula in C1 would be =VLOOKUP(A1,Sheet1!A1:D10,INDIRECT("B1")+1,FALSE)
 
Last edited:
Upvote 0
Sheet1
Your lookup Table is in A1:D10


Sheet2
PL in A1
1 In B1

Your formula in C1 would be =VLOOKUP(A1,Sheet1!A1:D10,INDIRECT("B1")+1,FALSE)

Many thanks

That works sport on.

Quick question though....where there is INDIRECT("B1"), how do i get that to change when i drag the formula down to other rows? Or do i need to manually change the cell reference?
 
Upvote 0

Forum statistics

Threads
1,224,567
Messages
6,179,571
Members
452,927
Latest member
whitfieldcraig

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top