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>

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>
<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>
INDIRECT(SUBSTITUTE($C$15," ",""))<o:p></o:p>
<tbody> </tbody>


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

<o:p> </o:p>

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

</o:p>


 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.

Aladin Akyurek

MrExcel MVP
Joined
Feb 14, 2002
Messages
85,209
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?
 

ukmikeb

Well-known Member
Joined
Jul 10, 2009
Messages
2,757
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
 

dangerousmouse

New Member
Joined
Jan 8, 2010
Messages
9
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!
 

Aladin Akyurek

MrExcel MVP
Joined
Feb 14, 2002
Messages
85,209

ADVERTISEMENT

How about those 54 "areas"?
 

dangerousmouse

New Member
Joined
Jan 8, 2010
Messages
9

ADVERTISEMENT

...or can I construct a Lookup Table and enter that table as an INDEX Area Option?
 

Aladin Akyurek

MrExcel MVP
Joined
Feb 14, 2002
Messages
85,209
...or can I construct a Lookup Table and enter that table as an INDEX Area Option?

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.
 

dangerousmouse

New Member
Joined
Jan 8, 2010
Messages
9
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:

dangerousmouse

New Member
Joined
Jan 8, 2010
Messages
9
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
 

Forum statistics

Threads
1,136,445
Messages
5,675,899
Members
419,591
Latest member
mersanko

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
Top