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
Bookmarks