Can INDEX functions be Variable?

dangerousmouse

New Member
Joined
Jan 8, 2010
Messages
9
Hi,<o:p></o:p>
<o:p> </o:p>



<o:p>
Hi,<o:p></o:p>

<o:p> </o:p>

I’ve had many happy years enjoying VLOOKUP, but now I’vemoved on to a deeper relationship with INDEX MATCH ;o)<o:p></o:p>

<o:p> </o:p>

<o:p> </o:p>

I am using INDEX MATCH to return values from a table with 54columns.<o:p></o:p>

<o:p> </o:p>

There are 3 criteria to MATCH -<o:p></o:p>

MATCH expressions are variable – they are taken from dependentdrop down lists in cells C6, C12 and C9<o:p></o:p>

<o:p> </o:p>
An example of my inelegant but working formula is:<o:p></o:p>

=IF(C18="AgeLimit",INDEX(AgeLimit,MATCH(1,(Reseller=C6)*(Level=C12)*(PolicyType=C9),0)),IF(C18="HazardousActivities",INDEX(Hazardous1,MATCH(1,(Reseller=C6)*(Level=C12)*(PolicyType=C9),0)),IF(C18="Valuables",INDEX(Valuables1,MATCH(1,(Reseller=C6)*(Level=C12)*(PolicyType=C9),0)))))<o:p></o:p>


I would like to avoid using 54 nested IF Statements toindicate which column the INDEX function should return values from.<o:p></o:p>

<o:p> </o:p>
My questions are:<o:p></o:p>

Can the INDEX function be variable also?<o:p></o:p>

Can anyone show me how to combine INDEX MATCH with INDIRECTSUBSTITUTE to make the INDEX function variable?<o:p></o:p>

<o:p> </o:p>
Possible Solutions:<o:p></o:p>

[TABLE="class: MsoNormalTable, width: 469"]
<tbody>[TR]
[TD="width: 626, bgcolor: transparent"] I found this on another Mr Excel post – the closest solution I have found in my research.<o:p></o:p>
<o:p> </o:p>
To make INDEX function variable:<o:p></o:p>
INDEX(INDIRECT(R1),MATCH("Ralph",INDIRECT(R1&"[Name]"),0),MATCH("Sales",INDIRECT(R1&"[HEADERS]"),0))<o:p></o:p>
[/TD]
[/TR]
[TR]
[TD="width: 626, bgcolor: transparent"] <o:p> </o:p>
Also, to delete any spaces so formula can work with multi word entries in a drop down list.<o:p></o:p>
[/TD]
[/TR]
[TR]
[TD="width: 626, bgcolor: transparent"] INDIRECT(SUBSTITUTE($C$15," ",""))<o:p></o:p>
[/TD]
[/TR]
</tbody>[/TABLE]


Thanks so much,<o:p></o:p>

<o:p> </o:p>

Mike<o:p></o:p>

</o:p>


 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Unfinished/incomplete formulas do not tell much about problems they purport to solve.

Care to post a scaled-down sample along with the actual results you want to see?
 
Upvote 0
Hi

Index has an Areas option which you could use like :-
Code:
=INDEX((AgeLimit,Hazardous1,Valuables1),MATCH(1,(Reseller=C6)*(Level=C12)*(PolicyType=C9),0),,MATCH(C18,{"AgeLimit","HazardousActivities","Valuables"},0))

hth
 
Upvote 0
Mike to ukmikeb

That's it.

I have read a lot of tutorials about how to understand and use INDEX.
Not one mentioned an Areas Option.

Genius.

Thanks!
 
Upvote 0
INDEX(INDIRECT(C18),MATCH-expression)

might be easier on you if C18 houses a regular definition name and there is a correlation between matching and area.


Yes Aladin, that works well with Named Ranges that match.

I now need to remove any spaces from the entries in C18 to match the Named Range
eg: C18 = Hazardous Activities Named Range = HazardousActivities
or
eg: C18 = Age Limit Named Range = AgeLimit

I tried your excellent method like this:

=INDEX(INDIRECT(SUBSTITUTE($C$18," ",""),MATCH(1,(Reseller=C6)*(Level=C12)*(PolicyType=C9),0))

... entered with shift + control + enter - it being an array formula

An error is returned - The formula is missing a parenthesis.

So close now - can you help me with this one last hurdle?

Thanks for your kind attention so far

Mike
 
Last edited:
Upvote 0
Yes Aladin, that works well with Named Ranges that match.

I now need to remove any spaces from the entries in C18 to match the Named Range
eg: C18 = Hazardous Activities Named Range = HazardousActivities
or
eg: C18 = Age Limit Named Range = AgeLimit

I tried your excellent method like this:

=INDEX(INDIRECT(SUBSTITUTE($C$18," ",""),MATCH(1,(Reseller=C6)*(Level=C12)*(PolicyType=C9),0))

... entered with shift + control + enter - it being an array formula

An error is returned - The formula is missing a parenthesis.

So close now - can you help me with this one last hurdle?

Thanks for your kind attention so far

Mike


Hello Again,

I solved this by looking at each parenthesis and inserting an extra one alongside.
This eventually gave me the answer based on Aladin's awesome combo.

{=INDEX(INDIRECT(SUBSTITUTE($C$18," ","")),MATCH(1,(Reseller=C6)*(Level=C12)*(PolicyType=C9),0))}

Thank you Everyone for your Direction and Guidance!

Mike
 
Upvote 0

Forum statistics

Threads
1,223,275
Messages
6,171,122
Members
452,381
Latest member
Nova88

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