Dynamic worksheet look up - index match 2-way look up

windb

New Member
Joined
Mar 12, 2016
Messages
23
Hi there,

I have an index match match 2-way look up, which returns data based on another tab. (The index match does a vertical look up and then a horizontal one). The formula works fine, but I would like to introduce a variable into the formula to so it looks up the 'correct' tab, corresponding with the value in column A. I'm not familiar with the Indirect formula, but have tried giving this a go with no success. Is this possible?

The formula needs to allow for the fact that I may have up to 20 or so receiving IDs/ tabs. The range for all tabs will the same, albeit the detail contained within the tabs will be different. Ordinarily, I would just use an IF statement, e.g. IF ABC, then look up the ABC tab, etc but this doesn't feel very efficient in instances where there will be multiple scenarios.

I have attached an image which shows the formula in red, where ideally I would like this to look up tab "CDE" automatically.

Many thanks - appreciate any help in advance!
 

Attachments

  • Excel image.png
    Excel image.png
    18.4 KB · Views: 24

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
i have made up an example - not following the image as difficult to see and match

i can change your formula BUT post it in the text of a post so i can copy

so the formula
=INDEX(Sheet2!B2:E5,MATCH(Sheet1!A3,Sheet2!A2:A5,0),MATCH(Sheet1!B3,Sheet2!B1:E1))

is replaced by
=INDEX(INDIRECT("'"&C6&"'!B2:E5"),MATCH(Sheet1!A6,INDIRECT("'"&C6&"'!A2:A5"),0),MATCH(Sheet1!B6,INDIRECT("'"&C6&"'!B1:E1"),0))

indirects can slow spreadsheets dow if used a lot

also the range will not change if you copy the formula as thats now in "" and so fixed

Book2
ABCDE
1
2
3a3Sheet2-a3
4
5
6a3sheet3sheet3-a3
Sheet1
Cell Formulas
RangeFormula
E3E3=INDEX(Sheet2!B2:E5,MATCH(Sheet1!A3,Sheet2!A2:A5,0),MATCH(Sheet1!B3,Sheet2!B1:E1))
E6E6=INDEX(INDIRECT("'"&C6&"'!B2:E5"),MATCH(Sheet1!A6,INDIRECT("'"&C6&"'!A2:A5"),0),MATCH(Sheet1!B6,INDIRECT("'"&C6&"'!B1:E1"),0))


sheet2
Book2
ABCDE
11234
2aSheet2-a1Sheet2-a2Sheet2-a3Sheet2-a4
3bSheet2-b1Sheet2-b2Sheet2-b3Sheet2-b4
4cSheet2-c1Sheet2-c2Sheet2-c3Sheet2-c4
5dSheet2-d1Sheet2-d2Sheet2-d3Sheet2-d4
Sheet2



sheet3
Book2
ABCDE
11234
2asheet3-a1sheet3-a2sheet3-a3sheet3-a4
3bsheet3-b1sheet3-b2sheet3-b3sheet3-b4
4csheet3-c1sheet3-c2sheet3-c3sheet3-c4
5dsheet3-d1sheet3-d2sheet3-d3sheet3-d4
Sheet3



also on dropbox - will only be for a few days

Note: Images are difficult to see , and also requires that I input all the data myself, which means I may make an error, which is very time consuming, and from my point of view less likely to get a response, if a complicated spreadsheet. Plus we cannot see any of the formulas used.

Therefore -

A SMALL sample spreadsheet, around 10-20 rows, would help a lot here, with all sensitive data removed, and expected results mocked up and manually entered, with a few notes of explanation.

This will possibly enable a quicker and more accurate solution for you.

MrExcel has a tool called “XL2BB” that lets you post samples of your data and will allow us to copy/paste your sample data into our Excel spreadsheets, saving a lot of time.

You can also test to see if it works ok, in the "Test Here" forum.

OR if you cannot get XL2BB to work, or have restrictions on your PC

then put the sample spreadsheet onto a share

I only tend to goto OneDrive, Dropbox or google docs , as I'm never certain of other random share sites and possible virus.
Please make sure you have a representative data sample and also that the data has been desensitised, remember this site is open to anyone with internet access to see - so any sensitive / personal data should be removed

Make sure you set any share or google to share to everyone
 
Upvote 0
thank you very much!

My working formula is as follows: =INDEX(ABC!$D$2:$I$1001,MATCH(Main!$B3,ABC!$C$2:$C$1001,0),MATCH(Main!C$2,ABC!$D$1:$I$1,0))

This works fine on row 3.

Row 4 also works fine =INDEX(ABC!$D$2:$I$1001,MATCH(Main!$B4,ABC!$C$2:$C$1001,0),MATCH(Main!C$2,ABC!$D$1:$I$1,0))

But then on Row 5 this is the formula =INDEX(ABC!$D$2:$I$1001,MATCH(Main!$B5,ABC!$C$2:$C$1001,0),MATCH(Main!C$2,ABC!$D$1:$I$1,0))

Note - the ABC sheet name has carried down. I would like this sheet name to be variable. The sheet names are all in column A. I will upload a mini-sheet shortly! Apologies, I did try earlier but this was blocked on my PC. Best wishes.
 
Upvote 0
so converting your formula using as template

=INDEX(INDIRECT("'"&C6&"'!B2:E5"),MATCH(Sheet1!A6,INDIRECT("'"&C6&"'!A2:A5"),0),MATCH(Sheet1!B6,INDIRECT("'"&C6&"'!B1:E1"),0))

this
=INDEX(ABC!$D$2:$I$1001,MATCH(Main!$B5,ABC!$C$2:$C$1001,0),MATCH(Main!C$2,ABC!$D$1:$I$1,0))
to
for row 3
=INDEX(INDIRECT("'"&$A3&"'!$D$2:$I$1001"),MATCH(Main!$B3,INDIRECT("'"&$A3&"'!C$2:$C$1001"),0),MATCH(Main!C$2,INDIRECT("'"&$A3&"'!D$1:$I$1"),0))

as typing you have loaded a xl2bb

can you also load for the ABC sheet and the CDE sheet
then i can recreate the sheet

unless this works
=INDEX(INDIRECT("'"&$A3&"'!$D$2:$I$1001"),MATCH($B3,INDIRECT("'"&$A3&"'!C$2:$C$1001"),0),MATCH(C$2,INDIRECT("'"&$A3&"'!D$1:$I$1"),0))

as i dont have data in ABC or CDE

Book3
ABCDEFGHIJK
1EXAMPLE ONLY
2RECEIVINGValueCat1Cat2Cat3Cat4Cat5Cat6Cat7Cat8Cat9
3ABC117#N/A#N/A#N/A#N/A#N/A#N/A#N/A#N/A#N/A
4ABC118#N/A#N/A#N/A#N/A#N/A#N/A#N/A#N/A#N/A
5CDE120#N/A#N/A#N/A#N/A#N/A#N/A#N/A#N/A#N/A
6CDE121#N/A#N/A#N/A#N/A#N/A#N/A#N/A#N/A#N/A
7CDE122#N/A#N/A#N/A#N/A#N/A#N/A#N/A#N/A#N/A
Sheet1
Cell Formulas
RangeFormula
C3:K7C3=INDEX(INDIRECT("'"&$A3&"'!$D$2:$I$1001"),MATCH($B3,INDIRECT("'"&$A3&"'!C$2:$C$1001"),0),MATCH(C$2,INDIRECT("'"&$A3&"'!D$1:$I$1"),0))
 
Last edited:
Upvote 0
Solution
Here is an extract from ABC

Mini-sheet.xlsx
ABCDEFGHI
1Cat1Cat2Cat3Cat4Cat5Cat6
2TESTABC99900000100
3TESTABC99800000100
4TESTABC99700000100
5TESTABC99600000100
6TESTABC99500000100
7TESTABC99400000100
8TESTABC99300000100
9TESTABC99200000100
10TESTABC99100000100
11TESTABC99000000100
12TESTABC98900000100
13TESTABC98800000100
14TESTABC98700000100
15TESTABC98600000100
16TESTABC98500000100
17TESTABC98400000100
18TESTABC98300000100
19TESTABC98200000100
20TESTABC98100000100
21TESTABC98000000100
22TESTABC97900000100
23TESTABC97800000100
24TESTABC97700000100
25TESTABC97600000100
26TESTABC97500000100
27TESTABC97400000100
28TESTABC97300000100
29TESTABC97200000100
ABC
 
Upvote 0
CDE looks very similar. Unfortunately, I can't send it all as there is a limit on the amount of cells . Column C runs from 999 down to 0
 
Upvote 0
so converting your formula using as template

=INDEX(INDIRECT("'"&C6&"'!B2:E5"),MATCH(Sheet1!A6,INDIRECT("'"&C6&"'!A2:A5"),0),MATCH(Sheet1!B6,INDIRECT("'"&C6&"'!B1:E1"),0))

this
=INDEX(ABC!$D$2:$I$1001,MATCH(Main!$B5,ABC!$C$2:$C$1001,0),MATCH(Main!C$2,ABC!$D$1:$I$1,0))
to
for row 3
=INDEX(INDIRECT("'"&$A3&"'!$D$2:$I$1001"),MATCH(Main!$B3,INDIRECT("'"&$A3&"'!C$2:$C$1001"),0),MATCH(Main!C$2,INDIRECT("'"&$A3&"'!D$1:$I$1"),0))

as typing you have loaded a xl2bb

can you also load for the ABC sheet and the CDE sheet
then i can recreate the sheet

unless this works
=INDEX(INDIRECT("'"&$A3&"'!$D$2:$I$1001"),MATCH($B3,INDIRECT("'"&$A3&"'!C$2:$C$1001"),0),MATCH(C$2,INDIRECT("'"&$A3&"'!D$1:$I$1"),0))

as i dont have data in ABC or CDE

Book3
ABCDEFGHIJK
1EXAMPLE ONLY
2RECEIVINGValueCat1Cat2Cat3Cat4Cat5Cat6Cat7Cat8Cat9
3ABC117#N/A#N/A#N/A#N/A#N/A#N/A#N/A#N/A#N/A
4ABC118#N/A#N/A#N/A#N/A#N/A#N/A#N/A#N/A#N/A
5CDE120#N/A#N/A#N/A#N/A#N/A#N/A#N/A#N/A#N/A
6CDE121#N/A#N/A#N/A#N/A#N/A#N/A#N/A#N/A#N/A
7CDE122#N/A#N/A#N/A#N/A#N/A#N/A#N/A#N/A#N/A
Sheet1
Cell Formulas
RangeFormula
C3:K7C3=INDEX(INDIRECT("'"&$A3&"'!$D$2:$I$1001"),MATCH($B3,INDIRECT("'"&$A3&"'!C$2:$C$1001"),0),MATCH(C$2,INDIRECT("'"&$A3&"'!D$1:$I$1"),0))
This is brilliant, seems to work perfectly:

=INDEX(INDIRECT("'"&$A3&"'!$D$2:$I$1001"),MATCH($B3,INDIRECT("'"&$A3&"'!C$2:$C$1001"),0),MATCH(C$2,INDIRECT("'"&$A3&"'!D$1:$I$1"),0))
 
Upvote 0

Forum statistics

Threads
1,223,937
Messages
6,175,512
Members
452,650
Latest member
Tinfish

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