Duplicate numbers in a listbox

MJW

New Member
Joined
Feb 3, 2004
Messages
2
Hi everyone,

I have a combobox filled with numbers, some of which appear several times, but i would like each number only to appear on the list once. This list will also increase as i add new entries.

Is it possible to add items to this list once rather than have duplicate entires?

Thanks in advance for any help!
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December

TommyGun

MrExcel MVP
Joined
Dec 9, 2002
Messages
4,202
Are the values in your list built from a Range of values, or are they stored elsewhere (i.e. in code, file, or database)?
 

Alan Nicoll

Board Regular
Joined
Feb 3, 2004
Messages
71
I don't know that a function exists to do this for you. You can certainly do a brute-force item-by-item check. That is:

Take item in list
Delete all subsequent occurrences of that item
Repeat until end of list encountered

HTH

Alan
 

TommyGun

MrExcel MVP
Joined
Dec 9, 2002
Messages
4,202

ADVERTISEMENT

Can you post the code you use to add items to this list (range)?
 

Alan Nicoll

Board Regular
Joined
Feb 3, 2004
Messages
71
Can you post the code you use to add items to this list (range)?

Not quite sure what you're asking. If the data is in a spreadsheet you bind the list to the cells using something like:
UserForm1.ListBox1.RowSource =
#VALUE!
 

TommyGun

MrExcel MVP
Joined
Dec 9, 2002
Messages
4,202
Well, seeing as the items need to be added to the range in some way (either manually or via code), this is probably the best place to check for duplicates. :devilish:
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,152,095
Messages
5,768,053
Members
425,451
Latest member
JohnBrooksBiddle

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
Top