Update a combo box

NDMDRB

Board Regular
Joined
Jun 20, 2016
Messages
164
Office Version
  1. 2016
Platform
  1. Windows
Hello,

I have a userform with some comboboxes and commendbuttons, one of the comboboxes named "cmb_Name"

In Sub UserForm_Initialize, I have below peace of code to show the suppliers names in the combobox

Code:
Dim rngName As Range
Dim ws As Worksheet
Set ws = Sheet8
For Each rngName In ws.Range("Suppliers_Name")
Me.cmb_Name.AddItem rngName.Value
Next rngName

And in the userform, there is a commend button to add new supplier named "cmdNewSupplier"

Everything works fine for now, but I need the combobox to be updated and get the new supplier name and show him in the list

I've tried to put the same code above at the end of the Sub cmdNewSupplier_Click

It shows the previous list and the new list, so all the previous names now appears two times and at the end appears the new name


Is there any way to fix this code or any way to update the cobmobox without duplicates?
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
Firstly you can replace all this
Code:
Dim rngName As Range
Dim ws As Worksheet
Set ws = Sheet8
For Each rngName In ws.Range("Suppliers_Name")
Me.cmb_Name.AddItem rngName.Value
Next rngName
with
Code:
Me.cmb_Name.List = Sheet8.Range("Suppliers_Name").Value
Then in "cmdNewSupplier" code put
Code:
Me.cmb_Name.Clear
Me.cmb_Name.List = Sheet8.Range("Suppliers_Name").Value
 
Upvote 0
Wow, thank you so much Fluff, this helps me a lot
 
Upvote 0
Glad to help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,214,606
Messages
6,120,490
Members
448,967
Latest member
visheshkotha

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