+ Reply to Thread
Results 1 to 8 of 8

VBA Userform Dependent Combobox

Hybrid View

  1. #1
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: VBA Userform Dependent Combobox

    To best describe or illustrate your problem you would be better off attaching a dummy workbook, the workbook should contain the same structure and some dummy data of the same type as the type you have in your real workbook - so, if a cell contains numbers & letters in this format abc-123 then that should be reflected in the dummy workbook.

    If needed supply a before and after sheet in the workbook so the person helping you can see what you are trying to achieve.

    Doing this will ensure you get the result you need!
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

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

+ Reply to Thread

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