View Single Post
 
Old 05-14-2020, 08:39 AM
Paskie_be Paskie_be is offline Windows 10 Office 2016
Novice
 
Join Date: May 2020
Posts: 4
Paskie_be is on a distinguished road
Question Multiple entries from ListBox

Hello,


I have created a word template with User Form. In the latter; I have one field (actually a ListBox) where people can choose several entries. The coding of this box is:
ListBoxMarking.List = Array("", "NATO", "The United Nations", "the African Union", "Troop Contributing States")

The idea is that people can choose any entry, be it one, two or more. These entries would then appear in the created Word document. If no option was chosen, nothing should appear. If any option is chosen, it ought to be preceded by the phrase "Releasable to ".

The coding for that is:
Private Function Marking() As String
Dim x As Integer
Marking = ""
For x = 0 To Me.ListBoxMarking.ListCount - 1
If Me.ListBoxMarking.Selected(x) Then
If Marking = "" Then
Marking = Me.ListBoxMarking.List(x)
Else: Marking = "Releasable to " & Marking & ", " & Me.ListBoxMarking.List(x)
End If
End If
Next x
End Function

The trouble is that the phrase "Releasable to " only appears when there is multiple choices and stays out when only on option is chosen.

Could you please advise to fix this?


Thanks,


Paskie_be
Reply With Quote