+ Reply to Thread
Results 1 to 7 of 7

vba excel - last listbox item transfer erasing all listbox items except last item

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    02-25-2013
    Location
    Colorado, US
    MS-Off Ver
    Microsoft 365 Apps
    Posts
    518

    Re: vba excel - last listbox item transfer erasing all listbox items except last item

    Thanks 6StringJazzer. Through some dissection this weekend, I see as you've pointed out that I was using a MultiSelect loop in the removal code for the ListBox2 set to SingleSelect property. I'm not sure if the example you sent with the Add event was missing something though, as the add event only adds the first row (minus header) to ListBox2. I've attached my working example with revisions to both the Add and Remove events.

    I am having an issue with the add event code however, and I'm not sure if it's because it's the nature of MulitSelect ListBoxes. It's somewhat minor but annoying. For some reason, the Add routine is not resetting itself after it runs, even if I reset all the ListBoxes at the end of the routine. The clue that it is not resetting is that if the Add event runs after initialization, the msgbox does not show up when the Add event is run again if nothing is selected in ListBox1. The Remove event works fine which leads me to believe it's because a MultiSelect ListBox is a different animal. I've tried:
    Private Sub resetLists ()
        Me.ListBox1.ListIndex = -1
        Me.ListBox2.ListIndex = -1
        For Count = 0 To Me!lbDaily.ListCount
            Me!ListBox1.Selected(Count) = False
        Next Count
        Me.ListBox1.Enabled = True
        Me.ListBox2.Enabled = True
    End Sub
    The only thing that works is Unloading and Showing the UserForm after the Add event occurs, so if I have to do that, I guess I can live with that.
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] VBA To populate listbox with duplicate item by increasing the item quantity
    By Sintek in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-01-2016, 07:51 AM
  2. [SOLVED] if anything in listbox select first item, if listbox empty do nothing (listbox in userform
    By mcdermott2 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-17-2015, 12:49 PM
  3. Transfer random listbox items to new listbox and then loop through selected items
    By narrowgate88 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-31-2013, 05:58 PM
  4. [SOLVED] Items in Userform Listbox are wider than list box. Need to see all character of item
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-09-2012, 06:40 AM
  5. How to number listbox items, enable a cmd button and move item lines?
    By Kimberley in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-28-2011, 09:10 AM
  6. Multi select Listbox Items selection based on other Listbox item selection.
    By srinivassathi in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-20-2011, 05:53 AM
  7. Transfer Item From Range1 to Range2 Using ListBox
    By hifliers in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-22-2009, 06:13 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1