Data Validation

snash

Board Regular
Joined
Jan 12, 2006
Messages
222
I've got a drop down list of customer names in C2. Now I'm thinking of adding a new region field in my file in C1. So if I do a validation of regions in C1, how would I get C2 to show only the list of customers associated to that region?

thanks in advance,
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Where does your Source data live?
You can do it with formulas... but it takes a lot of extra stuff to make it work.... ranks and counts, and IfBlanks... You "CAN" do it, but I would recommend using two active control comboboxes instead.

Code:
Sub GetUniqueAndCount()

    Dim d As Object
    Dim tmp As String
    Dim i As Integer
    Set d = CreateObject("scripting.dictionary")
    i = 1
    Do Until Cells(i, 1) = ""
        tmp = Trim(Cells(i, 1))
        If Len(tmp) > 0 Then d(tmp) = d(tmp) + 1
        i = i + 1
    Loop
    Me.ComboBox21.Clear

    For Each k In d.keys
        Me.ComboBox21.AddItem k
    Next k

End Sub

Private Sub ComboBox21_Change()
Me.ComboBox22.Clear

i = 1

Do Until Cells(i, 1) = ""
    If Cells(i, 1).Value = Me.ComboBox21.Value Then
    Me.ComboBox22.AddItem Cells(i, 2)

    End If
        i = i + 1
Loop
End Sub
 
Upvote 0
thanks, Can I just copy this code or do I need to do other things first? I will have about 5 regions in one drop down and then in another drop down there could be 20 customers associated to the relevant region
 
Upvote 0
Where do the regions and customers exist in your workbook? Do you have a separate tab that has the master list?


You will need other things... For example, I don't actually drop the value of the drop down into the cells where your old drop downs were.
 
Upvote 0

Forum statistics

Threads
1,224,824
Messages
6,181,186
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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