Userform ComboBox drop down list keeps duplicating the list

nathanr33

New Member
Joined
Aug 11, 2016
Messages
6
i have a userform with 3 drop down selection lists. everytime i click the arrow to list the dropdown it duplicates whats in the list over and over and over until i close the userform and re open it. is there some simple code that i can add to the userform to stop it from duplicating the lists.


Private Sub cmdAdd_Click()
'Copy input values to sheet.
Dim lRow As Long
Dim ws As Worksheet
Set ws = Worksheets("UserForm1")
lRow = ws.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
With ws
.Cells(lRow, 1).Value = Me.txtVin.Value
.Cells(lRow, 4).Value = Me.cboPassFail.Value
.Cells(lRow, 5).Value = Me.cboOperator.Value
.Cells(lRow, 6).Value = Me.cboQC.Value
.Cells(lRow, 7).Value = Me.txtComment.Value
End With

'Clear input controls.
Me.txtVin.Value = ""
Me.cboPassFail.Value = ""
Me.cboOperator.Value = ""
Me.cboQC.Value = ""
Me.txtComment.Value = ""

End Sub
Private Sub cboPassFail_DropButt*******()
'Populate control.
Me.cboPassFail.AddItem "PASS"
Me.cboPassFail.AddItem "FAIL"
End Sub


Private Sub cboOperator_DropButt*******()
'Populate control.
Me.cboOperator.AddItem "Willson"
Me.cboOperator.AddItem "Jerry"
Me.cboOperator.AddItem "Billy"
Me.cboOperator.AddItem "Adam"
Me.cboOperator.AddItem "John"
End Sub


Private Sub cboQC_DropButt*******()
'Populate control.
Me.cboQC.AddItem "SUPPLIER"
End Sub


Private Sub cmdClose_Click()
'Close UserForm.
Unload Me

End Sub




Private Sub TextTrans_Change()


End Sub


Private Sub Label11_Click()


End Sub


Private Sub Label12_Click()


End Sub


Private Sub Label9_Click()


End Sub


Private Sub txtEngine_Change()


End Sub
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Don't use the comboboxes own events to populate it, put the code to populate them in the userform's Initialize event.
Code:
Private Sub UserForm_Initialize()

    Me.cboPassFail.AddItem "PASS"
    Me.cboPassFail.AddItem "FAIL"

    Me.cboOperator.AddItem "Willson"
    Me.cboOperator.AddItem "Jerry"
    Me.cboOperator.AddItem "Billy" 
    Me.cboOperator.AddItem "Adam"
    Me.cboOperator.AddItem "John"

    Me.cboQC.AddItem "SUPPLIER"

End Sub
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top