OldManDemosthenes
New Member
- Joined
- Apr 19, 2011
- Messages
- 38
I am creating a userform with 2 multiselect listbox. Can anyone tell me how to make the selection(s) appear in column A for the first listbox and column B for the 2nd? Selection 1 in row 1, selection 2 in row 2, etc...
If possible I would also would like the userform to make sure that the user selects at least one option from either of the listbox. I've done this for the first listbox but I don't know how to incorporate both listbox at once.
My code so far is posted below
Thanks for the help!
Private Sub cbRun_Click()
Dim i As Long, msg As String, Check As String
With lbCity
For i = 0 To .ListCount - 1
If .Selected(i) Then
msg = msg & .List(i) & vbNewLine
End If
Next i
End With
If msg = vbNullString Then
MsgBox "You must select a Trade Area"
Exit Sub
Else
Check = MsgBox("You selected:" & vbNewLine & msg & vbNewLine & _
"Are you happy with your selections?", _
vbYesNo + vbInformation, "Please confirm")
End If
If Check = vbYes Then
If obCapita.Value = True Then Cells(2, 4) = "Capita" Else
If obHH.Value = True Then Cells(2, 4) = "Household"
If obCensus.Value = True Then Cells(3, 4) = "Census" Else
If obDOF.Value = True Then Cells(3, 4) = "DOF"
frmInput.Hide
Else
For i = 0 To lbCity.ListCount - 1
lbCity.Selected(i) = False
Next
End If
End Sub
If possible I would also would like the userform to make sure that the user selects at least one option from either of the listbox. I've done this for the first listbox but I don't know how to incorporate both listbox at once.
My code so far is posted below
Thanks for the help!
Private Sub cbRun_Click()
Dim i As Long, msg As String, Check As String
With lbCity
For i = 0 To .ListCount - 1
If .Selected(i) Then
msg = msg & .List(i) & vbNewLine
End If
Next i
End With
If msg = vbNullString Then
MsgBox "You must select a Trade Area"
Exit Sub
Else
Check = MsgBox("You selected:" & vbNewLine & msg & vbNewLine & _
"Are you happy with your selections?", _
vbYesNo + vbInformation, "Please confirm")
End If
If Check = vbYes Then
If obCapita.Value = True Then Cells(2, 4) = "Capita" Else
If obHH.Value = True Then Cells(2, 4) = "Household"
If obCensus.Value = True Then Cells(3, 4) = "Census" Else
If obDOF.Value = True Then Cells(3, 4) = "DOF"
frmInput.Hide
Else
For i = 0 To lbCity.ListCount - 1
lbCity.Selected(i) = False
Next
End If
End Sub