excel Userfrom复选框连接到带分隔符的单元格

envsm3lx  于 2023-05-08  发布在  其他
关注(0)|答案(1)|浏览(149)

我已经创建了用户表单来将数据输入到Excel工作表。用户表单包含文本框、组合框和复选框。我已经分开了两个不同的组,但不是在帧的复选框。2组,每组5个复选框。我在复选框属性中给出的组名称。复选框的值写为标题属性。
我给了这个代码来输入我想要的数据。

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

如果我选中了所有的复选框,如果我选中了一个复选框,则该值在此之后不会合并。我做错了什么。

wwtsj6pe

wwtsj6pe1#

如果选中SizSamp和FoldPaste,则可能发生这种情况。

If SizSamp.Value = True Then
    If selectedOptions1 <> "" Then
        selectedOptions1 = selectedOptions1 & " & "
    End If
    selectedOptions1 = selectedOptions1 & SizSamp.Caption
End If
End If

变更

End If
If SizSamp.Value = True Then
    If selectedOptions1 <> "" Then
        selectedOptions1 = selectedOptions1 & " & "
    End If
    selectedOptions1 = selectedOptions1 & SizSamp.Caption
End If

然后在FoldPaste上做同样的事情。

相关问题