LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 74
Default Macro doesn't work twice

OK, I give up. Can someone please tell me why the following macro works
perfectly the first time the TeamAddsListBox is clicked, but the second time
it is clicked, the TEAMLIST range and the TeamListBox are not updated from
the TeamAddsListBox.

Private Sub TeamAddsListBox_Click()
For a = 0 To TeamAddsListBox.ListCount - 1
If TeamAddsListBox.Selected(a) Then
TeamListBox.AddItem TeamAddsListBox.List(a)
End If
Next
For a = TeamAddsListBox.ListCount - 1 To 0 Step -1
If TeamAddsListBox.Selected(a) Then
TeamAddsListBox.Selected(a) = False
TeamAddsListBox.RemoveItem a
End If
Next
Range("TEAMLIST").Value = TeamListBox.List
Range("TEAMLIST").Select
Selection.Replace What:="#N/A", Replacement:=""
Range("TEAMLIST").sort Key1:=Range("TEAMLIST"), Order1:=xlAscending
Range("A84").Select
TeamListBox.List = Range("TEAMLIST").Value
End Sub

If I comment out the last line, the TEAMLIST is updated and sorted correctly
and the name is added to the TeamListBox, but it is just added onto the end
of the list. I need to have the list in the TeamListBox mirror the list in
TEAMLIST. The name is removed from the TeamAddsList (as it should be) in
either case. I have been stuggling with this all morning. Any help will be
greatly appreciated.

Thanks,
--
Jim T
 
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
Macro to update a column in a work based on another work sheet WickerMan New Users to Excel 1 December 4th 09 12:58 PM
Macro works Macro does not work Wanna Learn Excel Discussion (Misc queries) 4 March 24th 08 12:51 PM
If I have a work sheet protected and try to run a macro to hide rows or columns it won't work. Correct? Marc Excel Programming 2 July 12th 06 04:10 AM
how do you get (end down) to work in a macro? lcx2 Excel Worksheet Functions 1 March 24th 05 08:15 AM
why doesn't macro work? Alen32 Excel Programming 9 March 13th 05 04:51 PM


All times are GMT +1. The time now is 09:22 AM.

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

About Us

"It's about Microsoft Excel"