samedi 6 mai 2023

Userfrom Checkbox concatenate to cell with separators

I have created userform to enter data to excel sheet. The userform contains textbox, combobox and checkbox. I have separated the checkbox with two different group but not in frame. 2 groups with 5 checkbox each group. Group name i have given in checkbox properties. The value of the checkbox is written is Caption properties.

I have given this code to enter data i desired.

Dim selectedOptions1 As String
Dim selectedOptions2 As String
  If ColSamp.Value = True Then
    selectedOptions1 = ColSamp.Caption
     End If
     If Dummy.Value = True Then
        If selectedOptions1 <> "" Then
        selectedOptions1 = selectedOptions1 & " & "
    End If
    selectedOptions1 = selectedOptions1 & Dummy.Caption
End If
If gmg.Value = True Then
    If selectedOptions1 <> "" Then
        selectedOptions1 = selectedOptions1 & " & "
    End If
    selectedOptions1 = selectedOptions1 & gmg.Caption
End If
If LsrPrf.Value = True Then
    If selectedOptions1 <> "" Then
        selectedOptions1 = selectedOptions1 & " & "
    End If
    selectedOptions1 = selectedOptions1 & LsrPrf.Caption
If SizSamp.Value = True Then
    If selectedOptions1 <> "" Then
        selectedOptions1 = selectedOptions1 & " & "
    End If
    selectedOptions1 = selectedOptions1 & SizSamp.Caption
End If
End If
If Emboss.Value = True Then
    selectedOptions2 = Emboss.Caption
     End If
If Deboss.Value = True Then
    If selectedOptions2 <> "" Then
        selectedOptions2 = selectedOptions2 & " & "
    End If
    selectedOptions2 = selectedOptions2 & Deboss.Caption
End If
If DieCuting.Value = True Then
    If selectedOptions2 <> "" Then
        selectedOptions2 = selectedOptions2 & " & "
    End If
    selectedOptions2 = selectedOptions2 & DieCuting.Caption
End If
If WindPast.Value = True Then
    If selectedOptions2 <> "" Then
        selectedOptions2 = selectedOptions2 & " & "
    End If
    selectedOptions2 = selectedOptions2 & WindPast.Caption
If FoldPaste.Value = True Then
    If selectedOptions2 <> "" Then
        selectedOptions2 = selectedOptions2 & " & "
    End If
    selectedOptions2 = selectedOptions2 & FoldPaste.Caption
End If
End If

it is working if i checked all the check box if i'm checked one box between the value is not combining after that. What i'm doing wrong in this.




Aucun commentaire:

Enregistrer un commentaire