How to make a Data Validation Dependent Drop Down List From the precedent Row?

Lacan

Board Regular
Joined
Oct 5, 2016
Messages
228
Office Version
  1. 365
Platform
  1. Windows
Hello Guys,

Have this massive extent List that would like to make a Data Validation Dependent Drop Down List from the precedent row.

Will give you a sample data with 4 examples to be very clear that what is the goal in order to choose from Data Validation Dependent Drop Down List from the precedent row.

Can you help me?

Thanks a lot.


Book1
BCDEFGHIJK
2BrickCenterCityNameBrickCenterCityName
3299 Lx - Amadora (MÁgua - Sul)CENTRO CLINICO AVENIDAAmadoraAnnaExample 1299 Lx - Amadora (MÁgua - Sul)CENTRO CLINICO AVENIDAAmadoraAnna
4299 Lx - Amadora (MÁgua - Sul)CENTRO CLINICO AVENIDAAmadoraAnna SimonExample 2300 Lx - Amadora (MÁgua - Sul)Clínica LAR MEDICOSamoucoAnna
5299 Lx - Amadora (MÁgua - Sul)CENTRO CLINICO AVENIDAAmadoraAladinExample 3301 Lx - Amadora (MÁgua - Sul)Clínica LAR JONHAmadoraLuzia
6299 Lx - Amadora (MÁgua - Sul)CENTRO CLINICO AVENIDAAmadoraSergeExample 4302 Lx - Amadora (MÁgua - Sul)Clínica MEDICA SALisboaPedro
7299 Lx - Amadora (MÁgua - Sul)CENTRO CLINICO AVENIDAAmadoraFernando
8299 Lx - Amadora (MÁgua - Sul)CENTRO CLINICO AVENIDAAmadoraBlyde
9299 Lx - Amadora (MÁgua - Sul)CENTRO CLINICO AVENIDAAmadoraDynom
10300 Lx - Amadora (MÁgua - Sul)CENTRO CLINICO AVENIDAAmadoraVenom
11300 Lx - Amadora (MÁgua - Sul)CENTRO CLINICO FRANKAmadoraYalan
12300 Lx - Amadora (MÁgua - Sul)Clínica LAR MEDICOSamoucoAnna
13300 Lx - Amadora (MÁgua - Sul)Clínica LAR MEDICOSamoucoCosta
14300 Lx - Amadora (MÁgua - Sul)Clínica LAR MEDICOSamoucoMaria
15300 Lx - Amadora (MÁgua - Sul)Clínica LAR MEDICOSamoucoCesar
16300 Lx - Amadora (MÁgua - Sul)Clínica LAR MEDICOSamoucoCarlos
17301 Lx - Amadora (MÁgua - Sul)HospitalAmadoraMaria
18301 Lx - Amadora (MÁgua - Sul)Clínica LAR JONHAmadoraJesus
19301 Lx - Amadora (MÁgua - Sul)Clínica LAR JONHAmadoraMaria
20301 Lx - Amadora (MÁgua - Sul)Clínica LAR JONHAmadoraLuzia
21301 Lx - Amadora (MÁgua - Sul)Clínica MEDICA SALisboaGuilherme
22302 Lx - Amadora (MÁgua - Sul)Clínica MEDICA SALisboaRogerio
23302 Lx - Amadora (MÁgua - Sul)Clínica MEDICA SALisboaPedro
24302 Lx - Amadora (MÁgua - Sul)Dr Peter SaSamoucoAlbino
25302 Lx - Amadora (MÁgua - Sul)Consultorio Dr KingLisboaFernando
Folha6



1581376174648.png
 
Hi, Lacan
If you already have Dynamic Array function in your Office 365, then you can try this example of dependent data validation (but it's only 3 column data validation). It uses VBA + formula.
Let me know if you're interested in this method & need help to apply it for 4 column data validation in your workbook.
dhee - 3 data validation, dependent, dynamic array 365.xlsm

VBA Code:
'=================================================================================================
'=============== YOU MAY NEED TO ADJUST THE CODE IN THIS PART: ===================================

'sheet's name where the list for data validation is located. [in the sample: sheet "sheet2"]
Private Const sList As String = "sheet2"

'table's name where the list for data validation is located. [in the sample: "Table1"]
Private Const sTable As String = "Table1"

'the helper column
Private Const xH As String = "E"

'range where data validation is located
Private Const sDV1 As String = "B2:B10"  ' for data validation 1
Private Const sDV2 As String = "C2:C10"  ' for data validation 2
Private Const sDV3 As String = "D2:D10"  ' for data validation 2

'==================================================================================================
'==================================================================================================

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If Target.Cells.CountLarge > 1 Then Exit Sub
'    On Error GoTo skip:
    If Not Intersect(Target, Union(Range(sDV1), Range(sDV2), Range(sDV3))) Is Nothing Then
        Dim f As Range
        Dim MN As String, tx1 As String, tx2 As String, tx3 As String
       
        Application.EnableEvents = False
        Sheets(sList).Columns(xH).ClearContents

        Set f = Sheets(sList).ListObjects(sTable).DataBodyRange
        tx1 = f.Columns(1).Address
        tx2 = f.Columns(2).Address
        tx3 = f.Columns(3).Address
        MN = Me.Name & "!"
       
        With Sheets(sList).Range(xH & 1)
            If Target.Column = Range(sDV1).Column Then
                .Value = "=UNIQUE(" & tx1 & ")"
                           
            ElseIf Target.Column = Range(sDV2).Column And Target.Offset(, -1) <> "" Then
                .Value = "=UNIQUE(FILTER(" & tx2 & "," & tx1 & "=" & MN & Target.Offset(, -1).Address & "))"
           
            ElseIf Target.Column = Range(sDV3).Column And Target.Offset(, -1) <> "" And Target.Offset(, -2) <> "" Then
                .Value = "=UNIQUE(FILTER(" & tx3 & ",(" & tx1 & "=" & _
                MN & Target.Offset(, -2).Address & ")*(" & tx2 & "=" & MN & Target.Offset(, -1).Address & ")))"

            End If
        End With
       
        Application.EnableEvents = True

    End If


End Sub


Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.CountLarge <> 1 Then Exit Sub
    If Not Intersect(Target, Union(Range(sDV1), Range(sDV2))) Is Nothing Then
       
        Application.EnableEvents = False
            If Target.Column = Range(sDV1).Column Then
            Target.Offset(, 1).Resize(, 2).ClearContents
            ElseIf Target.Column = Range(sDV2).Column Then
            Target.Offset(, 1).ClearContents
            End If
        Application.EnableEvents = True
   
    End If
End Sub


Thank you ver much my Friend.

However to make crystal clear the goals I make another post thread with all data that everyone understands what want to achieve.

So please give your opinnion:

How to create a Data Validation Drop-down list based on another Data Validation Drop-down list in precedent Row? (Cascade Drop Down Menu)

Thanks again.
 
Upvote 0

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
I see the duplicated thread has been closed so I'll repost here my very slow (5 seconds per cycle on my laptop) response using Excel 2016 with CELL ADDRESS and INDIRECT functions.

Lacan.xlsx
ABCDEFGHIJKLMNO
1$L$4:$L$6$M$4:$M$5$N$4:$N$5$O$4:$O$5
2AreaCentreCityNameAreaCentreCityName$G$5$H$5$I$5
3299 GothamAdams ClinicGothamJohn302 XanaduHolby GeneralGothamMichaelAreaCentreCityName
4299 GothamAdams ClinicGothamSarah301 SherwoodFaith MedicalRomeGillian299 GothamAdams ClinicGothamMargaret
5299 GothamAdams ClinicGothamSimon299 GothamAdams ClinicParisJames301 SherwoodFaith MedicalParisJames
6299 GothamAdams ClinicParisMargaret302 Xanadu   
7299 GothamAdams ClinicParisJames    
8299 GothamFaith MedicalParisPeter    
9299 GothamFaith MedicalGothamVanessa    
10301 SherwoodFaith MedicalGothamSusan    
11301 SherwoodFaith MedicalRomeGillian    
12301 SherwoodHolby GeneralRomeAlex    
13301 SherwoodHolby GeneralRomeJames    
14302 XanaduHolby GeneralParisGary    
15302 XanaduHolby GeneralGothamMichael    
16302 XanaduClinic OssoParisThomas    
17302 XanaduClinic OssoMilanThomas    
18    
Sheet1
Cell Formulas
RangeFormula
L1:O1L1=CELL("address",L4)&":"&ADDRESS(COUNTIF(L$4:L$1000,"> ")+ROW(L$3),COLUMN())
M2:O2M2=ADDRESS(COUNTIF(G$3:G$10,"> ")+ROW(G$2),COLUMN(G$2))
L4:L18L4=INDEX(B$3:B$2500,MATCH(0,INDEX(COUNTIF(L$3:L3,B$3:B$2500),),0))&""
M4:M18M4=IFERROR(INDEX(C$3:C$2500,AGGREGATE(15,6,ROW(C$3:C$2500)-ROW($C$2)/((B$3:B$2500=INDIRECT(M$2))*(COUNTIF(M$3:M3,C$3:C$2500)=0)),1)),"")
N4:N18N4=IFERROR(INDEX(D$3:D$2500,AGGREGATE(15,6,ROW(D$3:D$2500)-ROW($C$2)/((C$3:C$2500=INDIRECT(N$2))*(B$3:B$2500=INDIRECT(M$2))*(COUNTIF(N$3:N3,D$3:D$2500)=0)),1)),"")
O4:O18O4=IFERROR(INDEX(E$3:E$2500,AGGREGATE(15,6,ROW(E$3:E$2500)-ROW($C$2)/((D$3:D$2500=INDIRECT(O$2))*(C$3:C$2500=INDIRECT(N$2))*(B$3:B$2500=INDIRECT(M$2))*(COUNTIF(O$3:O3,E$3:E$2500)=0)),1)),"")
Cells with Data Validation
CellAllowCriteria
G3:J12List=INDIRECT(L$1)
 
Upvote 0
Dear Toadstool,

U are the man, thanks again pal.

However want make a last small change in the structure like this:

1581811706298.png



1. Want to make tables with validation drop menu each one correletad with the corresponding reference in the R column.

2. The reference cell in the R column its any value in data validation menu.

ALL DATA:

Book1
BCDEFGHIJKLMNOPQRSTUVW
1$L$4:$L$6$M$4:$M$5$N$4:$N$5$O$4:$O$6
2areaCentreCityNameAreaCentreCityName$G$4$H$3$I$3
3299 GothamAdams ClinicGothamJohn299 GothamAdams ClinicGothamJohnAreaCentreCityName299 GothamCentreCityName
4299 GothamAdams ClinicGothamSarah299 Gotham299 GothamAdams ClinicGothamJohnAdams ClinicGothamSarah
5299 GothamAdams ClinicGothamSimon301 SherwoodFaith MedicalParisSarah
6299 GothamAdams ClinicParisMargaret302 Xanadu  Simon
7299 GothamAdams ClinicParisJames    
8299 GothamFaith MedicalParisPeter    301 SherwoodCentreCityName
9299 GothamFaith MedicalGothamVanessa    Holby GeneralRomeJames
10301 SherwoodFaith MedicalGothamSusan    
11301 SherwoodHolby GeneralRomeGillian    
12301 SherwoodHolby GeneralRomeAlex    
13301 SherwoodHolby GeneralRomeJames    302 XanaduCentreCityName
14302 XanaduHolby GeneralParisGary    Holby GeneralParisGary
15302 XanaduHolby GeneralGothamMichael    
16302 XanaduClinic OssoParisThomas
17302 XanaduClinic OssoMilanThomas
Folha4
Cell Formulas
RangeFormula
L1, M1:O1L1=CELL("endereço",L4)&":"&ADDRESS(COUNTIF(L$4:L$1000,"> ")+ROW(L$3),COLUMN())
M2:O2M2=ADDRESS(COUNTIF(G$3:G$10,"> ")+ROW(G$2),COLUMN(G$2))
L4:L15L4=INDEX(B$3:B$2500,MATCH(0,INDEX(COUNTIF(L$3:L3,B$3:B$2500),),0))&""
M4:M15M4=IFERROR(INDEX(C$3:C$2500,AGGREGATE(15,6,ROW(C$3:C$2500)-ROW($C$2)/((B$3:B$2500=INDIRECT(M$2))*(COUNTIF(M$3:M3,C$3:C$2500)=0)),1)),"")
N4:N15N4=IFERROR(INDEX(D$3:D$2500,AGGREGATE(15,6,ROW(D$3:D$2500)-ROW($C$2)/((C$3:C$2500=INDIRECT(N$2))*(B$3:B$2500=INDIRECT(M$2))*(COUNTIF(N$3:N3,D$3:D$2500)=0)),1)),"")
O4:O15O4=IFERROR(INDEX(E$3:E$2500,AGGREGATE(15,6,ROW(E$3:E$2500)-ROW($C$2)/((D$3:D$2500=INDIRECT(O$2))*(C$3:C$2500=INDIRECT(N$2))*(B$3:B$2500=INDIRECT(M$2))*(COUNTIF(O$3:O3,E$3:E$2500)=0)),1)),"")
Named Ranges
NameRefers ToCells
_FilterDatabase=Folha4!$B$2:$E$17L4:O15
area=Folha4!$B$3:$B$17L4:O15
Centre=Folha4!$C$3:$C$17M4:O15
City=Folha4!$D$3:$D$17N4:O15
Name=Folha4!$E$3:$E$17O4:O15
Cells with Conditional Formatting
CellConditionCell FormatStop If True
B3:E17Expression=contar.ses($B$3:$B$17;$G1048570;$C$3:$C$17;$H1048570)textNO
Cells with Data Validation
CellAllowCriteria
G3:J12List=INDIRETO(L$1)
T9:V11List=INDIRETO(Y$1)
T4:V6List=INDIRETO(Y$1)
T14:V16List=INDIRETO(Y$1)



Can you help with the formulas?

Again Toadstool, dont have words to express my gratitude.
 

Attachments

  • 1581811296252.png
    1581811296252.png
    32.4 KB · Views: 10
Upvote 0
Hi Lacan,

I'm not sure I understand the change. Are you saying you want to replace the input area format in columns G, H, I and J (all dropdown Data Validation lists) with a similar approach but using the format in columns R, S, T, U and V?

So column R would have a Data Validation list offering each unique Area, then the three rows for T, U and V would offer Centre, City and Name only under that Area?

At the moment I use the number of Areas entered to figure out which row is being populated but with the new style that probably would not work well. I guess I could use =CELL("Address") to see what was the last active cell, e.g. if it was R3 then column M would know to offer Centre from the R3 content, but that will take a while to figure out.
 
Upvote 0
Hi Toadstool,

To resume and to clarify even better:

1. Yes, want a similar approach - dropdown Data Validation lists only in this tables range T4:V6 ; T9:V11 and T14:V16 offering Centre, City and Name only under that Area (in column R).

2. Acording with data refence in column R (Area) should get the corresponding Centre, City and Name in this tables.

Examples:

R3 (Area) should only corresp Centre, City and Name in table range T4:V6;
R8 (Area) should only corresp Centre, City and Name in table T9:V11;
R13 (Area) should only corresp Centre, City and Name in table T14:V16;

3. Ask for not worry with data validation menu - unique values in column R.

Thanks again Pal.
 
Upvote 0
Lacan,

Even slower to support this format. Each section must be completed left to right as it build the completed Data Validation list from the entries just made..
Lacan3.xlsx
BCDEFGHIJKLMNOPQR
1$M$4:$M$6$N$4:$N$5$O$4:$O$5$P$4:$P$5ActiveAddress
2AreaCentreCityNameAreaCentreCityName$G$3$I$5$J$5$K$5$G$3
3299 GothamAdams ClinicGothamJohn299 GothamAdams ClinicGothamSarahAreaCentreCityName
4299 GothamAdams ClinicGothamSarahFaith MedicalParisPeter299 GothamAdams ClinicGothamMargaret
5299 GothamAdams ClinicGothamSimonAdams ClinicParisMargaret301 SherwoodFaith MedicalParisJames
6299 GothamAdams ClinicParisMargaret302 Xanadu   
7299 GothamAdams ClinicParisJamesAreaCentreCityName    
8299 GothamFaith MedicalParisPeter301 SherwoodHolby GeneralRomeJames    
9299 GothamFaith MedicalGothamVanessaFaith MedicalRomeGillian    
10301 SherwoodFaith MedicalGothamSusan    
11301 SherwoodFaith MedicalRomeGillian    
12301 SherwoodHolby GeneralRomeAlexAreaCentreCityName    
13301 SherwoodHolby GeneralRomeJames302 XanaduFaith Medical    
14302 XanaduHolby GeneralParisGary    
15302 XanaduHolby GeneralGothamMichael    
Sheet1
Cell Formulas
RangeFormula
M1:P1M1=CELL($R$1,M4)&":"&ADDRESS(COUNTIF(M$4:M$1000,"> ")+ROW(M$3),COLUMN())
N2N2=R2
O2:P2O2=ADDRESS(ROW(INDIRECT($Q$2)),COLUMN(I$1))
Q2Q2=CELL($R$1)
R2R2=CHOOSE(MIN(INT(ROW(INDIRECT($Q$2))+4)/5,3),CELL($R$1,G3),CELL(R1,G8),CELL($R$1,G13))
M4:M15M4=INDEX(B$3:B$2500,MATCH(0,INDEX(COUNTIF(M$3:M3,B$3:B$2500),),0))&""
N4:N15N4=IFERROR(INDEX(C$3:C$2500,AGGREGATE(15,6,ROW(C$3:C$2500)-ROW($C$2)/((B$3:B$2500=INDIRECT(N$2))*(COUNTIF(N$3:N3,C$3:C$2500)=0)),1)),"")
O4:O15O4=IFERROR(INDEX(D$3:D$2500,AGGREGATE(15,6,ROW(D$3:D$2500)-ROW($C$2)/((C$3:C$2500=INDIRECT(O$2))*(B$3:B$2500=INDIRECT(N$2))*(COUNTIF(O$3:O3,D$3:D$2500)=0)),1)),"")
P4:P15P4=IFERROR(INDEX(E$3:E$2500,AGGREGATE(15,6,ROW(E$3:E$2500)-ROW($C$2)/((D$3:D$2500=INDIRECT(P$2))*(C$3:C$2500=INDIRECT(O$2))*(B$3:B$2500=INDIRECT(N$2))*(COUNTIF(P$3:P3,E$3:E$2500)=0)),1)),"")
Cells with Data Validation
CellAllowCriteria
G3,G8,G13List=INDIRECT($M$1)
R1Listendereço,Address
I3:I5,I8:I10,I13:I15List=INDIRECT($N$1)
J3:J5,J8:J10,J13:J15List=INDIRECT($O$1)
K3:K5,K8:K10,K13:K15List=INDIRECT($P$1)
 
Upvote 0
Dear Toadstool,

First thank you very much - helped a lot.

Im now making the first tests - so far so great.

Last question - want to add another Area, Centre, City Name in G17 cell order.

In that case what which formulas do I have to to update and how so they can work all together?

Thanks again my friend.
 
Upvote 0
Dear Toadstool,

Just copy to another sheet but doesnt work.

What Im doing wrong?

Thanks again pal.
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,334
Members
452,636
Latest member
laura12345

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