LOOKUP or MATCH/INDEX?

delboy275

New Member
Joined
May 5, 2022
Messages
15
Office Version
  1. 2016
Platform
  1. Windows
Hi, I am using Excel 2016.

Question I have a table on sheet 1. first cell (B8) has a drop down list of distances 0 – 99, 100 - 199, 200 -299 etc. Second cell (C8) has drop down list of “types” A, B , C etc.

Sheet 3 has 3x different tables all with the same distances and a separate array list of “types”,

(1 array list of distances 0 – 99, 100 - 199, 200 -299 for types A & E types. (B3:L15)

1x array list of distances 0 – 99, 100 - 199, 200 -299 for types B, C, F & & G types (B18:L30)

1x array list of distances 0 – 99, 100 - 199, 200 -299 for types D & H types) (B33:L45)

I want the formulae to check which “distance” has been selected in cell B8, then check which “type” has been selected in cell C8, then select which of the three tables on sheet 3 to lookup use to output the correct value.

(Note: Sheet 3 has a list of distances down the left side and corresponding values to the right of the distances).



I will try and write it in plain english:

If (B8) is 0-99 metres and (C8) is type A or E then VLOOKUP table Sheet 2, (B3;L15) or

If (B8) is 100-200 metres and (C8) is type A or E then VLOOKUP table Sheet 3, (B4;L11) or



Also should this be done using VLOOKUP/HLOOKUP or MATCH/INDEX?

I am tying myself in knots.

Thanks in advance.

Del
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
With your table ranges being a bit all over the place, how about making all the Lookup Tables actual Excel tables ?
You can then simply use indirect to choose the table to lookup based the correct table name being used in the formula based on the types code.

See if this gives you any ideas.
Table Name tblTYPES

20220505 Select Different Lookup Table delboy275.xlsx
ABCDEF
1TypeLookup codeActual formulaTypesTable
2AOrange20AtblTypeAE
3BOrange920BtblTypeBCFG
4CtblTypeBCFG
5DtblTypeBCFG
6EtblTypeAE
Data
Cell Formulas
RangeFormula
C2:C3C2=VLOOKUP(B2,INDIRECT(VLOOKUP(A2,tblTYPES,2,FALSE)),2,FALSE)


Table names per table tblTYPES above

20220505 Select Different Lookup Table delboy275.xlsx
ABCDEFGH
1Col1Col2Col3Col1Col2Col3
2Apple10Apple910
3Orange20Orange920
4Pear30Pear930
LookupTables
 
Upvote 0
Hi Alex,
Many thanks for your reply.
I am having trouble interpreting your formulae, but I have had a go with my spreadsheet. see below.
H4 is where I want the result to be.
I have 3x tables (TYPE_AE, TYPE_BCFG and TYPE_DH).

=VLOOKUP(H4,INDIRECT(VLOOKUP(C4,tblTYPESAE,2,FALSE)),2,FALSE)

but how do i put this into formulae?
Thanks.

BCDEFGHJK
2
3DISTTYPE
4550-649A1.21.11.09109.090.00
5
6
7
8
9
10
11TYPES A & E
12
2 Plums​
3 Plums​
4 Plums​
5 Plums​
6 Plums​
7 Plums​
8 Plums​
9 Plums​
10 Plums​
11 Plums​
13200-24989929495969798989999
14250-349818790929395969798100
15350-449738186889093949697100
16450-549637480848790929596100
17
18
19TYPES B, C, F & G
20
2 Plums​
3 Plums​
4 Plums​
5 Plums​
6 Plums​
7 Plums​
8 Plums​
9 Plums​
10 Plums​
11 Plums​
21200-24989929495969798989999
22250-349818790929395969798100
23350-449738186889093949697100
24450-549637480848790929596100
25
26
27TYPES D & H
28
2 Plums​
3 Plums​
4 Plums​
5 Plums​
6 Plums​
7 Plums​
8 Plums​
9 Plums​
10 Plums​
11 Plums​
29200-24989929495969798989999
30250-349818790929395969798100
31350-449738186889093949697100
32450-549637480848790929596100
33
 
Upvote 0
1) You can't have H4 as both the formula result cell and a value in the Vlookup. Did you mean A4?
H4 is where I want the result to be.
=VLOOKUP(H4,INDIRECT(VLOOKUP(C4,tblTYPESAE,2,FALSE)),2,FALSE)

2) In your Row 4 - what determines which column to use in the other tables ie Column - 2 Plums 3 Plums 4 Plums etc

3) Your Example uses 550-649, which is not in any of the tables

4) Your Tables still don't look like Excel Tables (eg highlight B12 to L16 and hit Ctrl+T, Table has heading = Ticked, give the table a meaningful name.

5) You don't seem to have a Table Mapping your Type codes to the table names that you create.

Note: I would encourage to use Tables but you can get by with Range Names.
You previously indicated your lookup tables were on different sheets but here you have everything on the one sheet. Which is it ?
 
Upvote 0
For Tables have a look at this 3min video from Contextures
The accompanying article is here:-
How to Create Excel Tables and Fix Excel Table Problems

One of the benefits in this case, is that you don't need to know the sheet name of the table, you can just refer to the Table Name.
The fact that they autoexpand is also helpful for mapping / lookup tables.
 
Upvote 0
HI Alex,
Sorry I am getting confused with excel.

2. In row 4 the distance and Type A, B C, etc) will decide which table to use. (I know the distances are the same in the tables but other tables will be added later).
As shown Type A or E can only use the top table. Types B, C, F or G can only use the second table etc.

3. please replace 550-649 with 450-549. (It's because I didn't show you the full tables)

4. I have renamed each table as follows: NP_AE, NP_BCFG & NP_DH in the order they are shown (to separate the different "TYPES").

5. I think I need to start afresh with the coding.

6. The lookup tables have been created and are on different sheets as the tables are quite large. I extracted bits and put onto one sheet as I didn't want to breach confidentiality and hopefully to make it easier for you to view.
Regards.
 
Upvote 0
I have logged off for the night and will have a look tomorrow and put it together using your table names.
What do you want the table to be called that links the Type to the right lookup Table ? So I can use that in the formula. (Or did you call it TYPES)
 
Upvote 0
If we call the Table "EBI200_TRACK_TABLE".
Thanks again for your help.
Have a good night.
Tomorrow I am busy so will get back to you when possible.
Regards.
 
Upvote 0
If you have given all the tables the names as above this should work.
Formula H

20220505 Select Different Lookup Table delboy275.xlsx
ABCDEFGHIJKLMNOP
1
2
3DISTTYPETypesTable
4550-649A1.21.11.09109.09100ANP_AE
5BNP_BCFG
6CNP_BCFG
7DNP_DH
8ENP_AE
9FNP_BCFG
10GNP_BCFG
11HNP_DH
OPs Data
Cell Formulas
RangeFormula
H4H4=VLOOKUP($B4,INDIRECT(VLOOKUP($C4,EBI200_TRACK_TABLE,2,FALSE)),2,FALSE)


 
Upvote 0

Forum statistics

Threads
1,215,140
Messages
6,123,269
Members
449,093
Latest member
Vincent Khandagale

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