repetitions in the "combobox" why?

inactiveUser214710

Board Regular
Joined
Apr 27, 2012
Messages
171
hi everyone
In my exemplification project I have two option box(opt1;opt2); two checkboxes(chk1;chk2) and a combobox(cbo1).
I have: A macro (rng) for checkbox1 and (rng2) for checkbox2.
When I choose opt1 and chk1, cbo1 shows the correct information, but when I change the option in checkbox the combo show repetations. Why?
There are something wrong, please help me to solve. thank you
Code:
Private Sub chk1_Click()

If chk1.Value = True And chk2.Value = False Then
  rng     

End If
End Sub

Private Sub chk2_Click()

If chk2.Value = True Or chk1 - Value = False Then
  rng2     

End If
End Sub

=macros
Sub rng()

Dim rngCaixa As Range
Dim ws As Worksheet

  Set ws = Worksheets("sheet1")
For Each rngCaixa In ws.Range("caixa") 'range manager
  UserForm1.cbo1.AddItem rngCaixa.Value
  
Next rngCaixa

End Sub

Sub rng2()

Dim rngbanco As Range
Dim ws As Worksheet

  Set ws = Worksheets("sheet1")
For Each rngbanco In ws.Range("banco") 'range manager
  UserForm1.cbo1.AddItem rngbanco.Value
  
Next rngbanco

End Sub
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Add this line to the top of both rng subs
Code:
UserForm1.cbo1.Clear
 
Upvote 0
Glad to help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,214,982
Messages
6,122,573
Members
449,089
Latest member
Motoracer88

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