Cascading Dropdown using table with duplicates

LaneBrewer

New Member
Joined
Feb 1, 2022
Messages
4
Office Version
  1. 2016
Platform
  1. Windows
Hi Everyone,

Below I have the following worksheet sample:

Book2.xlsx
ABCDEFGH
1NameDivisionCenterJDSelect NameSelect Center
2Adams, StanAU1Dropdown of EmpNameDropdown with Center(s) based on G2
3Adams, StanAV1Carson, Rita
4Butler, TeddyBU2
5Butler, TeddyBV2
6Carson, RitaCX3
7Carson, RitaCY1
8Day, AllisonAZ4
9Evers, LeroyCU1
10
11
12EmpName<--Name of Range (Removed Duplicates)
13Adams, Stan
14Butler, Teddy
15Carson, Rita
16Day, Allison
17Evers, Leroy
Sheet1
Cells with Data Validation
CellAllowCriteria
G2Any value
G3List=EmpName


I am trying to figure out a formula to put into Data Validation that will then give me a dropdown that has all occurrences of Table1
for each EmpName chosen.

I have tried using =IFERROR(INDEX(GPTabPT,SMALL(IF(G3=EmpName,MATCH(ROW(EmpName),ROW(EmpName)),""),ROW($C1))),"")
and
=INDEX(GPTabPT,AGGREGATE(15,3,((EmpName=G3)/(EmpName=G3)*ROW(EmpName))-ROW(EmpName),ROWS(Sheet1!$B$2:Sheet1!B2)))
and
Offset() *I don't even remember what I tried but it didn't work.

I either get an error stating that I can't use arrays for Data Validation, the first value that matches, or I get no values in the dropdown. My actual table has over 100 unique values for EmpName so I don't want to have to create a named range for each to use the Indirect function


Excel Info:
Pro+ 2016
Version 2202 (Build 14931.20132 Click-to-Run)

Cheers,
Lane
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Maybe this option, create these Named Ranges

EmpName
Excel Formula:
=Sheet1!$A$13#

Center
Excel Formula:
=Sheet1!$B$13#


Book1
ABCDEFGHI
1NameDivisionCenterJDSelect NameSelect Center
2Adams, StanAU1Carson, RitaX
3Adams, StanAV1
4Butler, TeddyBU2NameDivisionJD
5Butler, TeddyBV2Carson, RitaC3
6Carson, RitaCX3
7Carson, RitaCY1
8Day, AllisonAZ4
9Evers, LeroyCU1
10
11
12EmpNameCenter (G2)
13Adams, StanX
14Butler, TeddyY
15Carson, Rita
16Day, Allison
17Evers, Leroy
Sheet1
Cell Formulas
RangeFormula
G5G5=FILTER(Table1[Name],(Table1[Name]=$G$2)*(Table1[Center]=$H$2),"")
H5H5=FILTER(Table1[Division],(Table1[Name]=$G$2)*(Table1[Center]=$H$2),"")
I5I5=FILTER(Table1[JD],(Table1[Name]=$G$2)*(Table1[Center]=$H$2),"")
A13:A17A13=SORT(UNIQUE(Table1[Name]))
B13:B14B13=FILTER(Table1[Center],Table1[Name]=G2)
Dynamic array formulas.
Cells with Data Validation
CellAllowCriteria
G2List=Empname
H2List=Center
 
Upvote 0
HI Ras,

Unfortunately my version of Excel does not include the FILTER() or SORT() functions nor will it allow me to use the # as you have shown. I've updated my sheet below to try and show better what I'm looking for.

Book2.xlsx
ABCDEFGH
1NameDivisionCenterJDSelect NameSelect Center
2Adams, StanAU1Dropdown of EmpNameDropdown with Center(s) based on G2
3Adams, StanAV1Carson, Rita
4Butler, TeddyBU2Carson, Rita
5Butler, TeddyBV2Butler, Teddy
6Carson, RitaCX3Day, Allison
7Carson, RitaCY1Adams, Stan
8Day, AllisonAZ4Adams, Stan
9Evers, LeroyCU1Adams, Stan
10
11
12EmpName<--Name of Range (Removed Duplicates)
13Adams, Stan
14Butler, Teddy
15Carson, Rita
16Day, Allison
17Evers, Leroy
Sheet1
Cells with Data Validation
CellAllowCriteria
G2Any value
G3:G9List=EmpName
H3:H9List?



Thank you.
 
Upvote 0
My actual table has over 100 unique values for EmpName so I don't want to have to create a named range for each to use the Indirect function
If the problem is to create the named ranges then you can use macro to create it.
Try this:
VBA Code:
Sub LaneBrewer1()

Dim i As Long, j As Long, n As Long
Dim va, tx As String

va = Range("A1:A9") 'Name
For i = 2 To UBound(va, 1) 'i = 2 because data start at row 2
    j = i
    Do
        i = i + 1
        If i > UBound(va, 1) Then Exit Do
    Loop While va(i, 1) = va(i - 1, 1)
    i = i - 1
        'replace space & comma with underscore
        tx = Replace(va(i, 1), " ", "_")
        tx = Replace(tx, ",", "_")

'    Debug.Print tx
    
    ActiveWorkbook.Names.Add Name:=tx, RefersTo:=Range(Cells(j, "C"), Cells(i, "C"))

Next

End Sub

It created the named ranges:
EXCEL_FTRxxao1fw.jpg


The code replaces space & comma with underscore because named range can't contain spaces and most punctuation characters. So the formula in the data-validation in H3 should be something like this:
=INDIRECT(SUBSTITUTE(SUBSTITUTE(G3," ","_"),",","_"))
 
Upvote 0
Solution
If the problem is to create the named ranges then you can use macro to create it.
Try this:
VBA Code:
Sub LaneBrewer1()

Dim i As Long, j As Long, n As Long
Dim va, tx As String

va = Range("A1:A9") 'Name
For i = 2 To UBound(va, 1) 'i = 2 because data start at row 2
    j = i
    Do
        i = i + 1
        If i > UBound(va, 1) Then Exit Do
    Loop While va(i, 1) = va(i - 1, 1)
    i = i - 1
        'replace space & comma with underscore
        tx = Replace(va(i, 1), " ", "_")
        tx = Replace(tx, ",", "_")

'    Debug.Print tx
   
    ActiveWorkbook.Names.Add Name:=tx, RefersTo:=Range(Cells(j, "C"), Cells(i, "C"))

Next

End Sub

It created the named ranges:
View attachment 61936

The code replaces space & comma with underscore because named range can't contain spaces and most punctuation characters. So the formula in the data-validation in H3 should be something like this:
=INDIRECT(SUBSTITUTE(SUBSTITUTE(G3," ","_"),",","_"))
Thank you for this Akuini. I was originally trying to do this without VBA but am starting to believe there is no other way with my version of Excel. This is an excellent solution. Thanks again.
 
Upvote 0
You're welcome, glad to help & thanks for the feedback.:)
 
Upvote 0
Since the list has over 100 unique values, you might want to have a searchable/autocomplete functionality on your data validation. You can try using a free add-in called "Search deList", here:
 
Upvote 0

Forum statistics

Threads
1,223,275
Messages
6,171,127
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