Updating specific colum from multi select list box on user form

Grendel12

New Member
Joined
Aug 31, 2018
Messages
2
Hi folks

I have a userform with a list box (called 'DidShow'), populated without any problems from an existing worksheet with names of potential attendees at training course.
The list box is set to 1 - fmMultiSelectMulti to enable the user to select any number of the available names in the list.

I have the below code, which will drop the first selected name into row 2 of column X on a sheet called "Workings" - correctly.
The code then cycles through to the end (up to 50 names) but at no point goes into the If statement (If DidShow.Selected(lngItem) Then) to add any additionally selected names into column X as required.
When multiple items are selected, they are highlighted blue on the user form, but as soon as the first selected name is added to column X all others are then deselected - is this causing the fact that no further names are added to column X? If so, how do I keep that focus on selected names so they populate the required area?
Any pointers greatly appreciated - I have been trying to sort this out for weeks!!
Cheers in advance!!




Dim lngItem As Long
For lngItem = 0 To DidShow.ListCount - 1
If DidShow.Selected(lngItem) Then
With Sheets("Workings")
.Cells(.Rows.Count, "X").End(xlUp).Offset(1).value = DidShow.List(lngItem)
End With
End If
Next lngItem
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Can you please supply all the code, not just a portion?
Also when posting code please use code tags, the # icon in the reply window
 
Last edited:
Upvote 0
Hi Fluff

Apologies, new to the forum.

There isn't much more to the code actually, but below is the whole thing - EmailArchive is just a subroutine (still to be written but have used the same previously so no problem), and the frmAvailableSessions.Show just shows the previous form again, and work fine.

Many thanks!

Code:
Private Sub CommandButton1_Click()


    Dim lngItem As Long


    For lngItem = 0 To DidShow.ListCount - 1
        If DidShow.Selected(lngItem) Then
            With Sheets("Workings")
                .Cells(.Rows.Count, "X").End(xlUp).Offset(1).value = DidShow.List(lngItem)
            End With
        End If

    Next lngItem


    Unload Me
    
    EmailArchive
    
    frmAvailableSessions.Show
        
End Sub
 
Upvote 0
Apologies, I wasn't clear.
Could you supply all the code in the UserForm module?
 
Upvote 0

Forum statistics

Threads
1,221,569
Messages
6,160,557
Members
451,656
Latest member
SBulinski1975

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top