Consulting

Results 1 to 4 of 4

Thread: VB Userform with combobox help

  1. #1

    VB Userform with combobox help

    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

  2. #2
    Knowledge Base Approver VBAX Guru GTO's Avatar
    Joined
    Sep 2008
    Posts
    3,368
    Location
    Hi Kelly,

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

    Thanks,

    Mark

  3. #3
    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

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]

    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
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •