Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 59
Default Removing items from listbox

I have (2) listboxes (List_AddTo - List_AddFrom). I have populated List_AddTo
with values from a Spreadsheet range. The List_AddFrom listbox is initially
populated from via VBA. I am having difficulty removing items from
List_AddFrom when they match List_AddTo items:

'Validate List_AddFrom Listbox with List_AddTo listbox and remove items as
necessary
If List_AddTo.ListIndex = -1 Then Exit Sub
If List_AddFrom.ListIndex = -1 Then Exit Sub
If Not cbDupicates Then
For i = 0 To List_AddTo.ListCount - 1
For j = 0 To List_AddFrom.ListCount - 1
If List_AddTo.list(i) = List_AddFrom.list(j) Then
List_AddFrom.RemoveItem j
End If
Next j
Next i
End If

Any ideas as to what I am doing wrong?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Removing items from listbox

I had to take out the test for cbDuplicates and the ListIndex tests for -1
to test it, but after doing so it worked fine for me.

Check that these values are not set incorrectly.

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"asmenut" wrote in message
...
I have (2) listboxes (List_AddTo - List_AddFrom). I have populated

List_AddTo
with values from a Spreadsheet range. The List_AddFrom listbox is

initially
populated from via VBA. I am having difficulty removing items from
List_AddFrom when they match List_AddTo items:

'Validate List_AddFrom Listbox with List_AddTo listbox and remove items as
necessary
If List_AddTo.ListIndex = -1 Then Exit Sub
If List_AddFrom.ListIndex = -1 Then Exit Sub
If Not cbDupicates Then
For i = 0 To List_AddTo.ListCount - 1
For j = 0 To List_AddFrom.ListCount - 1
If List_AddTo.list(i) = List_AddFrom.list(j) Then
List_AddFrom.RemoveItem j
End If
Next j
Next i
End If

Any ideas as to what I am doing wrong?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 59
Default Removing items from listbox

Thanks Bob.
I also had to remove the List_AddTo.ListIndex test and the CB Duplicates.
Works fine now. Gotta a new question for the group. Within the list box I
have a string "Bulletin Requested" that I need to highlight (Bold, red, etc)
to let the user know that this string will cause things to happen if it is
removed (i.e List_AddTo to List_AddFrom). This is the only string that needs
it. I tried loading the code for this in various locations (from the initial
spreadsheet read, to the Compare). Is there a way that I can do this?


"Bob Phillips" wrote:

I had to take out the test for cbDuplicates and the ListIndex tests for -1
to test it, but after doing so it worked fine for me.

Check that these values are not set incorrectly.

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"asmenut" wrote in message
...
I have (2) listboxes (List_AddTo - List_AddFrom). I have populated

List_AddTo
with values from a Spreadsheet range. The List_AddFrom listbox is

initially
populated from via VBA. I am having difficulty removing items from
List_AddFrom when they match List_AddTo items:

'Validate List_AddFrom Listbox with List_AddTo listbox and remove items as
necessary
If List_AddTo.ListIndex = -1 Then Exit Sub
If List_AddFrom.ListIndex = -1 Then Exit Sub
If Not cbDupicates Then
For i = 0 To List_AddTo.ListCount - 1
For j = 0 To List_AddFrom.ListCount - 1
If List_AddTo.list(i) = List_AddFrom.list(j) Then
List_AddFrom.RemoveItem j
End If
Next j
Next i
End If

Any ideas as to what I am doing wrong?




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
Removing Data Validation (Listbox) NoodNutt Excel Worksheet Functions 6 March 8th 08 12:35 PM
Removing (trading) an item in a listbox asmenut Excel Programming 0 September 28th 04 02:09 AM
Adding Items to a ListBox-Unique Items Only jpendegraft[_14_] Excel Programming 2 May 2nd 04 02:27 AM
Items in a Listbox Todd Huttenstine Excel Programming 1 April 26th 04 03:36 PM
removing selection focus in listbox Craig Wilks[_2_] Excel Programming 2 August 13th 03 12:15 PM


All times are GMT +1. The time now is 07:42 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"