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

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.

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)?
 
Upvote 0

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
 
Upvote 0

TommyGun

MrExcel MVP
Joined
Dec 9, 2002
Messages
4,202
Can you post the code you use to add items to this list (range)?
 
Upvote 0

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!
 
Upvote 0

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:
 
Upvote 0

Forum statistics

Threads
1,187,175
Messages
5,962,044
Members
438,578
Latest member
MrJimC

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