I am making a excel userform with two comboboxes. One combox retrieves data from sheet3 (Column A) named "CompaniesandSubsidiaries". Then on the basis of first combobox, second combobox retrieves sub-category data. But problem is column A has data repetition. I have attached an image.
What I am trying is:
Private Sub Combobox1_DropButtonClick()
Dim rng As Range
Dim ws As Worksheet
Set ws = Worksheets("CompaniesandSubsidiaries")
For Each rng In ws.Range("Companies")
Me.ComboBox1.AddItem rng.Value
Next rng
End Sub
Private Sub ComboBox2_DropButtonClick()
Dim rng As Range
Dim ws As Worksheet
Set ws = Worksheets("CompaniesandSubsidiaries")
For Each rng In ws.Range("Providers")
Me.ComboBox2.AddItem rng.Value
Next rng
End Sub
I made a formula for both "column A and B" named companies and providers respectively. But It repeats the values. That I don't want.
What I want is to get the data dynamically from sheet3 for first combobox as company names (With no duplication)and then next combobox will enable and it will show the provider list corresponding with the company name.
Please provide a simple and easily understandable code. Thanks