# Indirect Vlookup with IF statements

#### thewiseguy

##### Well-known Member
Hi all. Having trouble combining functions.

Here is my formula which needs some work:

=IFERROR(VLOOKUP(B2,INDIRECT(VLOOKUP(C2,TableNames,2)),8,0),"")

instead of returning the value in the 8th column, I want to add these IF conditions:

=IF(E2≤20,17)
=IF(E2 is between 21-50, 18)
=IF(E2 is between 51-100, 19)
=IF(E2 ≥ 100,20)

is this possible?

### Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December

#### Fluff

##### MrExcel MVP, Moderator
Replace the 8 with
16+MATCH(E2,{0,21,51,101},1)

#### thewiseguy

##### Well-known Member
Replace the 8 with
16+MATCH(E2,{0,21,51,101},1)

sorry, I completely gave the wrong information. In my above example where you see, 17,18,19,20 - these represent the column numbers to lookup in the vlookup

#### Fluff

##### MrExcel MVP, Moderator
In that case please post some sample data using the XL2BB add-in, showing expected results & why.
Also please update you account details, to show what version of Excel you are using.

#### thewiseguy

##### Well-known Member

This my BOM tab (bill of materials). It will have any number of items in the "B" column.

Proposal5.xlsm
ABCDEF
1ManufacturerItemFixtureCategoryProduct IDQtyCost
2T-1T-1 Lighting 135W LED Linear High Bay w/ Occ. Sensor 5KHighBayLinearT1-G2HBLED/U/135-50-OS108
Sheet1

I am trying to get the cost of the item in column B, based on the qty (Column E) - (prices goes down as qty goes up).

On multiple separate tabs, I have tables. My indirect with vlookup formula that I mentioned above, is the formula I am trying to use.

The value in this example that should be returned would be \$104

Proposal5.xlsm
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABAC
1EMA DESCRIPTIONDESCRIPTIONECM CategoryECM Spec.ReplacesECM SizeMFGPART NO.ECM LumensNO. LAMPSLAMP WATTSNO. FIXTURESFIXTURE WATTSSYSTEM WATTSECM LIFEECM TEMPLamp Cost1-20PC21-50PC51-100PC101-200PCTOTAL ECM COSTLABORECM UNIT INCENTIVEMEASURE CODENJSS Proposed Fix TypeNJSS Fix/Lamp Desc.N/RNotes
2T-1 Lighting 321W LED Linear High Bay 4K321W LED Linear High Bay 4KHighBayLinear2FTT-1 LightingT1-HBLED/B/321-401321321500004000\$259.00\$234.00\$227.00\$220.0030150PL11LED - DLC FixtureLED High-Bay and Low-Bay Fixtures >250W N
3T-1 Lighting 321W LED Linear High Bay 5K321W LED Linear High Bay 5KHighBayLinear2FTT-1 LightingT1-HBLED/B/321-501321321500005000\$259.00\$234.00\$227.00\$220.0030150PL11LED - DLC FixtureLED High-Bay and Low-Bay Fixtures >250W N
4T-1 Lighting 135W LED Linear High Bay w/ Occ. Sensor 4K135W LED Linear High Bay w/ Occ. Sensor 4KHighBayLinear2FTT-1 LightingT1-G2HBLED/U/135-40-OS1135135500004000\$111.00\$109.00\$106.00\$104.003075PL10LED - DLC FixtureLED High-Bay and Low-Bay Fixtures >125W to ≤250W N
5T-1 Lighting 135W LED Linear High Bay w/ Occ. Sensor 5K135W LED Linear High Bay w/ Occ. Sensor 5KHighBayLinear2FTT-1 LightingT1-G2HBLED/U/135-50-OS1135135500005000\$111.00\$109.00\$106.00\$104.003075PL10LED - DLC FixtureLED High-Bay and Low-Bay Fixtures >125W to ≤250W N
Sheet4

#### Fluff

##### MrExcel MVP, Moderator
Assuming that you are looking up the value in col B of sheet4, then just replace the 8 in your formula with the formula I supplied.

#### thewiseguy

##### Well-known Member

Assuming that you are looking up the value in col B of sheet4, then just replace the 8 in your formula with the formula I supplied.

so it looks like the formula is not accounting for quantities from 1-20.

also, the formula works for quantities from 21-200, however it is returning the value from the column left of where it should be.

#### Fluff

##### MrExcel MVP, Moderator
If E2 <21 it will pull data from the 17 column of the lookup range, which is what you said you wanted.

#### thewiseguy

##### Well-known Member
so it looks like the formula is not accounting for quantities from 1-20.

also, the formula works for quantities from 21-200, however it is returning the value from the column left of where it should be.

*edit - i changed the 16 to 17 and it is now working.

i can't thank you enough - that is extremely helpful and impressive.

thank you!

#### Fluff

##### MrExcel MVP, Moderator
You're welcome & thanks for the feedback.

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

1,164,659
Messages
5,838,645
Members
430,559
Latest member
jm5498

### 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.

### Which adblocker are you using?

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

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