Cannot get Combobox to populate range based on previous Combobox value

Challis

New Member
Joined
Oct 22, 2017
Messages
21
Hello everyone.
Mr.Excel is an amazing resource, I'm trying to leverage everyone's expertise once again.
I have a userform with comboboxes the populates the last row of table. When the user selects a certain "AREA" in cmbAREA combobox, i want to show a list of "UNIT" related to that "AREA" in cmbUnit combobox. Below is the code I have put together. My issue is when the user selects an "AREA", no list is populating the "UNIT" combobox. Similarly for the next relationship down with "TYPE1" and TYPE2. Not sure what I am doing wrong. Help would be much appreciated.

Code:
Private Sub UserForm_Initialize()
'Variable declaration
Dim idVal As Integer
Dim ws As Worksheet
Set ws = ThisWorkbook.Sheets("Register")


'Defining the last row in the Data Sheet ad IdVal
idVal = ws.Cells(Rows.Count, "A").End(xlUp).Row + 1


'Update next available id on the userform
frmData.txtSEQUENCENUMBER = idVal - 99


'Enters ranges for comboboxes
    With ThisWorkbook.Sheets("Lookup")
        cmbREV.List = .Range("A2:A" & .Range("A" & .Rows.Count).End(xlUp).Row).Value
        cmbAREA.List = .Range("B2:D" & .Range("B" & .Rows.Count).End(xlUp).Row).Value


        Application.EnableEvents = False
        cmbUNIT.Clear
        Application.EnableEvents = True
        
        Select Case cmbAREA.Text
        Case "BLD"
        cmbUNIT.List = .Range("D2:D" & .Range("D" & .Rows.Count).End(xlUp).Row).Value
        Case "CO2"
        cmbUNIT.List = .Range("E2:E" & .Range("E" & .Rows.Count).End(xlUp).Row).Value
        Case "DOM"
        cmbUNIT.List = .Range("F2:F" & .Range("F" & .Rows.Count).End(xlUp).Row).Value
        Case "FLR"
        cmbUNIT.List = .Range("G2:G" & .Range("G" & .Rows.Count).End(xlUp).Row).Value
        Case "INL"
        cmbUNIT.List = .Range("H2:H" & .Range("H" & .Rows.Count).End(xlUp).Row).Value
        Case "LNG"
        cmbUNIT.List = .Range("I2:I" & .Range("I" & .Rows.Count).End(xlUp).Row).Value
        Case "SAF"
        cmbUNIT.List = .Range("J2:J" & .Range("J" & .Rows.Count).End(xlUp).Row).Value
        Case "SRV"
        cmbUNIT.List = .Range("K2:K" & .Range("K" & .Rows.Count).End(xlUp).Row).Value
        Case "STL"
        cmbUNIT.List = .Range("L2:L" & .Range("L" & .Rows.Count).End(xlUp).Row).Value
        Case "UTL"
        cmbUNIT.List = .Range("M2:M" & .Range("M" & .Rows.Count).End(xlUp).Row).Value
        End Select
        
        cmbTYPE1.List = .Range("N2:N" & .Range("N" & .Rows.Count).End(xlUp).Row).Value


        Application.EnableEvents = False
        cmbTYPE2.Clear
        Application.EnableEvents = True
        
        Select Case cmbTYPE1.Text
        Case "INSPECTION"
        cmbTYPE2.List = .Range("O2:O" & .Range("O" & .Rows.Count).End(xlUp).Row).Value
        Case "NDT"
        cmbTYPE2.List = .Range("P2:P" & .Range("P" & .Rows.Count).End(xlUp).Row).Value
        Case "SCOPE"
        cmbTYPE2.List = .Range("Q2:Q" & .Range("Q" & .Rows.Count).End(xlUp).Row).Value
        Case "VENDOR"
        cmbTYPE2.List = .Range("R2:R" & .Range("R" & .Rows.Count).End(xlUp).Row).Value
        Case "COMPLIANCE"
        cmbTYPE2.List = .Range("S2:S" & .Range("S" & .Rows.Count).End(xlUp).Row).Value
        End Select
        
        cmbPERSON1.List = .Range("T2:T" & .Range("T" & .Rows.Count).End(xlUp).Row).Value
        cmbPERSON2.List = .Range("T2:T" & .Range("T" & .Rows.Count).End(xlUp).Row).Value
        txtEQUIPMENT.Text = "GGP-"
    End With
End Sub
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).

Forum statistics

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