Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Using RemoveItem with a combobox

I have two lists of names. One is several hundred names long. The other is <
20. They are stored in separate worksheets.

I have a combo box that is populated with the large list of names. Then what
I want to do is remove any names from the combo box list if they are in the
second list.

It appears that while I can do
cmbobox1.AddItem Name
I cannot do
cmbobox1.RemoveItem Name

If I understand correctly, RemoveItem requires the row number to remove.

So, what is the best way to find the row number for the item that I want to
delete?


Thanks,

Dan Perkins
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Using RemoveItem with a combobox

I was able to write a function that would loop through the large list and
return the index number of a name from the smaller list. RemoveItem worked
for that.

I can't think of any better methods, but if someone has an idea, I would
love to hear it.

Thanks,

Dan Perkins

"Dan Perkins" wrote:

I have two lists of names. One is several hundred names long. The other is <
20. They are stored in separate worksheets.

I have a combo box that is populated with the large list of names. Then what
I want to do is remove any names from the combo box list if they are in the
second list.

It appears that while I can do
cmbobox1.AddItem Name
I cannot do
cmbobox1.RemoveItem Name

If I understand correctly, RemoveItem requires the row number to remove.

So, what is the best way to find the row number for the item that I want to
delete?


Thanks,

Dan Perkins

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 269
Default Using RemoveItem with a combobox

Dan, I presumed your smaller list is in a range on the active
worksheet. So, I just put a list of things in h3:h7 that were among
the items I had already loaded into combobox1. This code seeks out
those items and removes them from combobox1. Not very pretty. I'd
like to see one of the large brains improve on it. You may already
have something along these lines, but I thought I'd pass it along. I
did reset the listindex to the first item in the combobox in case the
listindex item had been removed. James

Dim a As Integer, cell As Range
For Each cell In Range("h3:h7")
For a = Me.ComboBox1.ListCount - 1 To 0 Step -1
If Me.ComboBox1.List(a) = cell Then
Me.ComboBox1.RemoveItem a
End If
Next a
Next cell
Me.ComboBox1.ListIndex = 0

Dan Perkins wrote:
I was able to write a function that would loop through the large list and
return the index number of a name from the smaller list. RemoveItem worked
for that.

I can't think of any better methods, but if someone has an idea, I would
love to hear it.

Thanks,

Dan Perkins

"Dan Perkins" wrote:

I have two lists of names. One is several hundred names long. The other is <
20. They are stored in separate worksheets.

I have a combo box that is populated with the large list of names. Then what
I want to do is remove any names from the combo box list if they are in the
second list.

It appears that while I can do
cmbobox1.AddItem Name
I cannot do
cmbobox1.RemoveItem Name

If I understand correctly, RemoveItem requires the row number to remove.

So, what is the best way to find the row number for the item that I want to
delete?


Thanks,

Dan Perkins


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Using RemoveItem with a combobox

hi,
I was checking for removing items from listbox and i found your code very
useful.Thanks for that,just wanna remove all the items from the listbox.is
this the only way?or there is some other practical way?
thanks again,you save some time for me:)

--
Regards,
Baha


"Zone" wrote:

Dan, I presumed your smaller list is in a range on the active
worksheet. So, I just put a list of things in h3:h7 that were among
the items I had already loaded into combobox1. This code seeks out
those items and removes them from combobox1. Not very pretty. I'd
like to see one of the large brains improve on it. You may already
have something along these lines, but I thought I'd pass it along. I
did reset the listindex to the first item in the combobox in case the
listindex item had been removed. James

Dim a As Integer, cell As Range
For Each cell In Range("h3:h7")
For a = Me.ComboBox1.ListCount - 1 To 0 Step -1
If Me.ComboBox1.List(a) = cell Then
Me.ComboBox1.RemoveItem a
End If
Next a
Next cell
Me.ComboBox1.ListIndex = 0

Dan Perkins wrote:
I was able to write a function that would loop through the large list and
return the index number of a name from the smaller list. RemoveItem worked
for that.

I can't think of any better methods, but if someone has an idea, I would
love to hear it.

Thanks,

Dan Perkins

"Dan Perkins" wrote:

I have two lists of names. One is several hundred names long. The other is <
20. They are stored in separate worksheets.

I have a combo box that is populated with the large list of names. Then what
I want to do is remove any names from the combo box list if they are in the
second list.

It appears that while I can do
cmbobox1.AddItem Name
I cannot do
cmbobox1.RemoveItem Name

If I understand correctly, RemoveItem requires the row number to remove.

So, what is the best way to find the row number for the item that I want to
delete?


Thanks,

Dan Perkins



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
RemoveItem resetting Value in ComboBox Drummer361 Excel Programming 2 August 16th 06 06:53 PM
MSFlexGrid RemoveItem gti_jobert[_132_] Excel Programming 2 June 21st 06 11:30 AM
RemoveItem - ComboBox Mike Excel Programming 1 May 16th 06 04:51 PM
Combobox options based on the input of another combobox afmullane[_5_] Excel Programming 1 May 3rd 06 01:44 PM
ComboBox list reliant on the entry from a different ComboBox ndm berry[_2_] Excel Programming 4 October 4th 05 04:40 PM


All times are GMT +1. The time now is 03:24 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"