Let's try again then. I assume you mean you want the output to look like H18 (not F18).
Private Sub cmdOkay_Click()
Dim i As Long, msg As String, Check As String
msg = "The pets selected are: "
'Generate a list of the selected items
With ListBox1
For i = 0 To .ListCount - 1
If .Selected(i) Then
msg = msg & .List(i) & ", "
End If
Next i
End With
If msg <> "The pets selected are: " Then
msg = Left$(msg, Len(msg) - 2) & "."
End If
If msg = "The pets selected are: " Then
'If nothing was selected, tell user and let them try again
MsgBox "Nothing was selected! Please make a selection!"
Exit Sub
Else
'Ask the user if they are happy with their selection(s)
Check = MsgBox(msg & vbNewLine & _
vbNewLine & "Are you happy with your selections?", _
vbYesNo + vbInformation, "Please confirm")
End If
If Check = vbYes Then
'Unload the userform since user is happy with selection(s)
Sheets("Sheet1").Range("H19").Value = msg
Unload Me
Else
'User wants to try again, so clear listbox selections and
'return user to the userform
For i = 0 To ListBox1.ListCount - 1
ListBox1.Selected(i) = False
Next
End If
End Sub
Bookmarks