Userform 2 comboboxes

brentcook

Board Regular
Joined
Nov 28, 2016
Messages
78
I have a form that has 2 data validation list cells. The first is linked to a table column. The second contains the folowing formula:

=OFFSET(Contacts!$A$2,MATCH($U$4,School,0)-1,1,COUNTIF(School,$U$4),1)

It populates based on the column to the right of the matches of the 1st column. Then I have multiple other cells that autopopulate based on that cell.

I asked a question last weeked, but got no responses, so decided to try a different angle. I decided to make a user form with comboboxes. The first one was easy to link to the desired column. The second is not. I am a VBA infant (if that isn't obvious yet). I was hoping someone would be willing to help me accomplish the above formula for the second combobox.

Any help is greatly appreciated.

Thanks
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
I'm sorry. I have a worksheet, not a form. I mistyped. I "created" a user form that has two comboboxes in it. The second list needs to list to be refined based on what was entered into the first list. Then I plan on having that put into the worksheet to carry out the rest of my tasks. A starting point on the code for the 2nd would be immensly helpful!
 
Upvote 0
I'm going to keep trying. I have tried coding it out, but I can't (not surprisingly) figure it out.

Here's what I have:

Code:
Private Sub ComboBox1_Change()

Dim x As Long
Dim Counselor As Range
Dim myTable As ListObject
Dim myArray As Variant
Dim TempArray As Variant
Const sRngName As String = "Contacts"


    Dim sGrp As String
    
    Set myTable = contacts.Sheet
    Temp.Array = myTable.DataBodyRange
    sGrp = ComboBox1.List(ComboBox1.ListIndex, 1)
    ComboBox2.Clear
    For x = 1 To Counselor.Rows.Count
        If School1.Cells(x, 2) = sGrp Then
            ComboBox2.AddItem Counselor.Cells(x, 1)
        End If
    Next x
End Sub

Is anyone able to help out? Thanks in advance for trying.
 
Upvote 0
Just an update in case there are any users who are struggling with something similar. I worked around the issue. I kept the data validation. I inserted a combobox over the 1st cell. It allowed me to take advantage of the autofill function of the combobox. I then used the code

Code:
Private Sub ComboBox1_Change()



Dim ws As Worksheet


Set ws = Worksheets("Team Sheet")


ActiveSheet.Unprotect


ws.Range("U4") = ComboBox1.Value


ActiveSheet.Protect


End Sub

Just update the ws.Range to the correct cell you are looking for.

Then the rest of the data validation continued to work just as before.

If you are not much into coding and need a little better explaination, feel free to message me directly.
 
Upvote 0

Forum statistics

Threads
1,214,585
Messages
6,120,399
Members
448,957
Latest member
Hat4Life

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