brianfosterblack
Active Member
- Joined
- Nov 1, 2011
- Messages
- 251
I have this code in a command button in a Userform and in this I have a multiselect listbox named ClientList
I use the code below to put the contents selected in the listbox into column AW in my workbook.
In making adjustments to this I cut of the end of the code and the last 2 lines are showing an error. Can anyone assist with what has been cut off as this was working perfectly before.
One other question. Is there a way to prevent some names in the listbox from being selected"
I use the code below to put the contents selected in the listbox into column AW in my workbook.
In making adjustments to this I cut of the end of the code and the last 2 lines are showing an error. Can anyone assist with what has been cut off as this was working perfectly before.
One other question. Is there a way to prevent some names in the listbox from being selected"
VBA Code:
Private Sub CommandButton1_Click()
Dim x As Long
Dim varSelected() As String
Dim i As Integer
i = i - 1
With ClientList
For x = 0 To .ListCount - 1
If .Selected(x) Then
i = i + 1
ReDim Preserve varSelected(i)
varSelected(i) = .List(x)
End If
Next x
End With
If i = -1 Then Exit Sub
Range(Cells(1, 49), Cells(UBound(varSelected) + 1, 49)) = _
WorksheetFunction.Transpose(Me.HideUnload FrmClientList
End Sub