Combining indirect and index/match

odonovanc

Board Regular
Joined
Oct 4, 2017
Messages
60
Office Version
  1. 365
Can someone help me combine an indirect with an index/match. Here is my index/match formula:

=INDEX('2017'!H5:S16,MATCH(B9,'2017'!B5:B18,0),MATCH(C4,'2017'!H4:S4,0))

This works perfectly. Obviously it is referencing data in a 2017 tab. But if the date in c4 is a 2018 date, I need it to lookup the 2018 tab instead of the 2017 tab. Hope that makes sense.
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Try =INDEX('2017'!H5:S16,MATCH(B9,IF(YEAR(C4)=2017,INDEX('2017'!B5:B18),INDEX('2018'!B5:B18)),0),MATCH(C4,IF(YEAR(C4)=2017,INDEX('2017'!H4:S4),INDEX('2018'!H4:S4)),0))
(I hope I got the parenthesis right..
 
Upvote 0
Tells me I have entered too few arguments for this function. WHen I click ok it highlights the b18 in the formula. More info as I don't think the path you started will work. I am starting with a data set I cannot manipulate. So what is on the 2017 and 2018 tabs I have to leave alone. Those tabs have the month in mmm format.

So my c4 sell is also in mmm format. So it might just say FEB. I have in c5 the corresponding year. (2017 in this case). So if we are doing an index and match and not an indirect, I need it to use the 2017 tab if cell c5 is is 2017 and the 2018 tab if cell c5 is 2018.

Hope that makes sense.
 
Upvote 0
I changed your formula to the following:

=VLOOKUP(B9,INDIRECT("'"&YEAR(C5)&"'!B5:H18"),MATCH(C4,INDIRECT("'"&YEAR(C5)&"'!B4:S4"),0),0)

I get a reference error. C5 is where I have the year which is also the tab names (2017 or 2018). c4 is the 3 digit month mmm.

Any ideas?
 
Upvote 0
That's what one often runs into when one changes the start situation for which a formula is provided.

Does this meet the changed situation?

=VLOOKUP(B9,INDIRECT(C5&"!B5:H18"),MATCH(C4,INDIRECT(C5&"!B4:S4"),0),0)
 
Upvote 0
I got it working. The following formula for anyone who may stumble on this thread:

=VLOOKUP($B9,INDIRECT(C$5&"!$B$5:$S$18"),MATCH(C$4,INDIRECT(C$5&"!$B$4:$S$4"),0),0)

Changing the first indirect to my whole set of data (going to S instead of H fixed the problem. I added the absolute and relative references for my copying purposes.

Thanks. You are awesome.
 
Last edited:
Upvote 0
I got it working. The following formula for anyone who may stumble on this thread:

=VLOOKUP($B9,INDIRECT(C$5&"!$B$5:$S$18"),MATCH(C$4,INDIRECT(C$5&"!$B$4:$S$4"),0),0)

Changing the first indirect to my whole set of data (going to S instead of H fixed the problem. I added the absolute and relative references for my copying purposes.

Thanks. You are awesome.

You are welcome. I seem I picked up the H from your initial attempt and did not notice H and S difference.:rofl:
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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