Results 1 to 8 of 8

VBA Userform Dependent Combobox

Threaded View

  1. #5
    Registered User
    Join Date
    09-08-2011
    Location
    UK
    MS-Off Ver
    Excel 2007
    Posts
    70

    Re: VBA Userform Dependent Combobox

    Okay, I have put together a table as an example of what I will be working with. What I would like ideally is:
    • Each of the column headers to form an option in Combobox 1 (More will be added)
    • Each of the values in the cells under the Headers to represent dependent options in Combobox 2 (these will also change, so need to comboboxes to change accordingly)
    • Also, Instead of populating the existing comboboxes in the code with the “AddItem” command, I would like to reference the relevant column on the “Data Input” sheet.

    I have included a small piece of existing code to give some idea of where I am at and how I have got there.
    What I really need now is the code to do the above, an explanation of what the code is doing would be great – and crucially, how to insert the new code into the existing code so it works!
    I hope that has clarified?


    Private Sub UserForm_Initialize()				
    				
            Application.Visible = False				
            				
            txtCustomer.Value = ""				
    				
            txtDetails.Value = ""				
            				
            txtResDetails = ""				
            				
            txtDate.Value = Format(Date, "dd/mm/yyyy")				
            				
            txtTime.Value = Format(Time, "hh:mm")				
            				
    With cboOperator				
    				
    .AddItem "Operator 1"				
    				
            .AddItem "Operator 2"				
    				
            .AddItem "Operator 3"				
    				
            .AddItem "Operator 4"				
    				
            .AddItem "Operator 5				
            				
     End With				
    				
        cboOperator.Value = ""				
        				
    With cboIssue				
    				
    .AddItem "Missing"				
    				
            .AddItem "Quality"				
    				
            .AddItem "Short Delivered"				
    				
            .AddItem "Damaged"				
    				
            .AddItem "Late"				
    				
     End With				
    				
        cboIssue.Value = ""				
        				
    End Sub				
    				
    Private Sub cmdExit_Click()				
        				
        Unload Me				
        Application.Quit				
    				
    End Sub				
    				
    				
    Private Sub cmdClear_Click()				
    				
        Call UserForm_Initialize				
        				
    End Sub				
    				
    Private Sub cmdUnlock_Click()				
    				
    If Me.txtPassword.Value = "password" Then				
    				
    Unload Me				
    				
    Application.Visible = True				
    				
    Else				
    				
    Me.Hide				
    				
    Retry = MsgBox("The password is incorrect. Do you wish to try again?", vbYesNo, "Retry?")				
    				
    Select Case Retry				
    				
    Case Is = vbYes				
    				
    Me.txtPassword.Value = ""				
    				
    Me.txtPassword.SetFocus				
    				
    Me.Show				
    				
    Case Is = vbNo				
    				
    Unload Me				
    				
    End Select				
    				
    End If				
    				
    End Sub
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1