Populating a listbox from an excel column

  • Thread starter Thread starter john.9.williams
  • Start date Start date
J

john.9.williams

I want to populate a list box with data from a column in excel. say
column a sheet 1. the data in the column will have repeated data in
it, but i only want this data added once in the listbox.

e.g column a could be

red
blue
red
yellow
blue
red
red
yellow

but i only want to display in the ist box

red
blue
yellow


I know how to populate a listbox based on a range but cant seem to
work this out

hope someone can help

John
 
Hi John,

Each time you pick up a new entry, loop through the listbox entries
you already have to see if there is a duplicate.

'Create a For Next Loop to read all the items in the List Box
For Item = 0 to ListBox.ListCount - 1

If ListBox.List(Item) <> {your next candidate} then
(Add the candidate to the list)
Exit for
else
'Duplicate, do nothing
end if

Next item
 
Hi John,

Each time you pick up a new entry, loop through the listbox entries
you already have to see if there is a duplicate.

'Create a For Next Loop to read all the items in the List Box
For Item = 0 to ListBox.ListCount - 1

  If ListBox.List(Item) <> {your next candidate} then
   (Add the candidate to the list)
   Exit for
  else
   'Duplicate, do nothing
  end if

Next item

thanks, just been thinking i think i would need to use a combo box
instead of a list, would the code be much different

john
 
Back
Top