PDA

View Full Version : VB Userform with combobox help



kellyhell
05-10-2011, 01:57 AM
I have a UserForm with a ComboBox populated from a list on an excel sheet.

When the user selects a value from this list I would like a further ComboBox to show a list of values based on the first ComboBox.

I want the process to be similar to the =INDIRECT function in Excel formula.

For example the user selects "Telephone" from the first box and the next box would only show a list of Telephones or the user selects "Computer" and the next box would show a list of Computers.

Thanks in advance

GTO
05-10-2011, 02:25 AM
Hi Kelly,

Can you attach a sample workbook, so that we can see the lists' layouts?

Thanks,

Mark

kellyhell
05-10-2011, 02:40 AM
Unfortunately I am unable to upload the file due to restrictions on the network where I work.

Basically the UserForm has a combobox with the RowSource property set to a named range on my workbook.

Once a value is selected a VLookup enters a value into a textbox called "descripBox".

The next combobox would look at "descripBox" value and only show a list based on that value. The lists are held in the workbook under a separate sheet and named the same as the list names in comobox 1.

For example. The VLookup list would show Telephone, Computer, Fax. The data sheet with the info for the combobox would be named the same and have models of telephones, computers, faxes.

Hope this makes sense

Bob Phillips
05-10-2011, 03:36 AM
Private Sub cmbProducts_Change()
Dim colNum As Long
Dim rng As Range

colNum = Application.Match(Me.cmbProducts.Value, Rows(1), 0)
Set rng = Range(Cells(2, colNum), Cells(2, colNum).End(xlDown))
Me.cmbItems.List = Application.Transpose(rng)

End Sub