# Can INDEX functions be Variable?

#### dangerousmouse

##### New Member
Hi,<o></o>
<o> </o>

<o>
Hi,<o></o>

<o> </o>

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

<o> </o>

<o> </o>

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

<o> </o>

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

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

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

=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></o>

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

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

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

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

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

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

Thanks so much,<o></o>

<o> </o>

Mike<o></o>

</o>

### Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.

#### Aladin Akyurek

##### MrExcel MVP
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
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
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

ADVERTISEMENT

How about those 54 "areas"?

#### dangerousmouse

##### New Member
How about those 54 "areas"?

What do you mean?

That there is a limit?

#### dangerousmouse

##### New Member

ADVERTISEMENT

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

#### Aladin Akyurek

##### MrExcel MVP
...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
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
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

Replies
36
Views
1K
Replies
3
Views
105
Replies
5
Views
145
Replies
7
Views
210
Replies
7
Views
126

Threads
1,141,062
Messages
5,704,060
Members
421,325
Latest member
tapete86

### 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

### 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