Using INDEX and refering to a Drop down

umaks

New Member
Joined
Dec 28, 2017
Messages
2
Hi, I basically want to create a drop down where you can select an age group and it simply lists the top 20 medical conditions in one column, number of admissions last year and this year, in the next two columns.

Basically I have five tables by age group - 20s, 30s, 40s, 50s, 60s

For each table, the column headings are Medical Condition (where the rows contain the list of the types of conditions), column 2016/17 YTD (rows containing the number of admissions for each condition), and column 2017/18 YTD (again, listing the number of admissions for each condition).

I have created Defined Name for each of the five tables - (I.e defined names are the age groups).

I then created a drop down list of the Defined Names - (which are the five age groups).

I now want to create a separate table which includes the list of top 20 medical conditions (and corresponding activity) for whichever age group you select from the toggle.

I thought it would be as simple as doing =index($b$4,3,1), where $B$4 refers to drop down which contains the Defined names (I.e the age group) I have just created. The 3 would refer to the third row, and 1 referring to the first column.
(I would have therefore created a whole table so then it would refer to the exact position, but the data would change according to the drop down toggle).
Why does it not pick up $B$4 as the array or Defined name.

How else can I crack this nut? Your help would be much appreciated :)
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Make sure your Defined names match up exactly with your dropdown list.

I just made an example sheet, with 3 named ranges, "Test", "Test2" and "Test3". I made a data validation dropdown in B1 from a list of "Test", "Test2" and "Test3" and when I use

Code:
=index(indirect(B4),2,2)

and switch between the data validation options it works correctly. I tried with different row and column numbers, and all works fine.
 
Last edited:
Upvote 0
ajamess has put his finger on the main problem. But if you want the list of conditions to be listed in order, you might need some additional formulas. For example:

BCDEFGHIJ
20s
Medical Condition2016/17 YTD2017/18 YTD
Age RangeTop 20 ConditionsCountAcne
TwentiesCholeraStubbed toe
MalariaFlu
Year RangeStubbed toeAsthma
2017/18 YTDHayfeverHayfever
AsthmaBad hair day
Bad hair dayBroken leg
FluCholera
AcneMalaria
Broken legDizziness
Dizziness

<colgroup><col style="width: 25pxpx"><col><col><col><col><col><col><col><col><col></colgroup><thead>
</thead><tbody>
[TD="align: center"]1[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]2[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]3[/TD]

[TD="align: right"][/TD]

[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: right"]1[/TD]
[TD="align: right"]8[/TD]

[TD="align: center"]4[/TD]

[TD="align: right"][/TD]

[TD="align: right"]25[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: right"]14[/TD]
[TD="align: right"]23[/TD]

[TD="align: center"]5[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: right"]25[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: right"]20[/TD]
[TD="align: right"]15[/TD]

[TD="align: center"]6[/TD]

[TD="align: right"][/TD]

[TD="align: right"]23[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: right"]6[/TD]
[TD="align: right"]17[/TD]

[TD="align: center"]7[/TD]

[TD="align: right"][/TD]

[TD="align: right"]19[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: right"]1[/TD]
[TD="align: right"]19[/TD]

[TD="align: center"]8[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: right"]17[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: right"]13[/TD]
[TD="align: right"]17[/TD]

[TD="align: center"]9[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: right"]17[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: right"]12[/TD]
[TD="align: right"]7[/TD]

[TD="align: center"]10[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: right"]15[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: right"]11[/TD]
[TD="align: right"]25[/TD]

[TD="align: center"]11[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: right"]8[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: right"]9[/TD]
[TD="align: right"]25[/TD]

[TD="align: center"]12[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: right"]7[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: right"]23[/TD]
[TD="align: right"]1[/TD]

[TD="align: center"]13[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: right"]1[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

</tbody>
Sheet3

[TABLE="width: 85%"]
<tbody>[TR]
[TD]Worksheet Formulas[TABLE="width: 100%"]
<thead>[TR="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]
[TH="width: 10px"]Cell[/TH]
[TH="align: left"]Formula[/TH]
[/TR]
</thead><tbody>[TR]
[TH="width: 10px, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]E4[/TH]
[TD="align: left"]=IFERROR(LARGE(INDEX(INDIRECT($B$4),0,MATCH($B$7,INDEX(INDIRECT($B$4),1,0),0)),ROWS($E$4:$E4)),"")[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
</tbody>[/TABLE]

[TABLE="width: 85%"]
<tbody>[TR]
[TD]Array Formulas[TABLE="width: 100%"]
<thead>[TR="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]
[TH="width: 10px"]Cell[/TH]
[TH="align: left"]Formula[/TH]
[/TR]
</thead><tbody>[TR]
[TH="width: 10px, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]D4[/TH]
[TD="align: left"]{=IF(E4="","",INDEX(INDIRECT($B$4),SMALL(IF(INDEX(INDIRECT($B$4),0,MATCH($B$7,INDEX(INDIRECT($B$4),1,0),0))=E4,ROW(INDEX(INDIRECT($B$4),0,1))-ROW(INDEX(INDIRECT($B$4),1,1))+1),COUNTIF($E$4:$E4,E4)),1))}[/TD]
[/TR]
</tbody>[/TABLE]
Entered with Ctrl+Shift+Enter. If entered correctly, Excel will surround with curly braces {}.
Note: Do not try and enter the {} manually yourself[/TD]
[/TR]
</tbody>[/TABLE]




The range H2:J100 has a named range of "Twenties". The other age ranges are defined just the same. In B4 is your drop down list for the age range, and in B7 I put in a drop down for the year. With those in place, you can use the formulas in E4 and D4 to get the list of conditions, sorted by frequency. It will dynamically change as you change the dropdowns in B4 and B7. Hope this helps.
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,279
Members
452,630
Latest member
OdubiYouth

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