英文:
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.
我已创建用户窗体以输入数据到Excel工作表。用户窗体包含文本框、组合框和复选框。我将复选框分成两个不同的组,但没有放在框架中。每个组有5个复选框。组名在复选框属性中指定。复选框的值写在标题属性中。
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.
如果我勾选了所有复选框,它可以工作,但如果我只勾选了一个复选框,之后的值就不会组合起来。我在这里做错了什么?
英文:
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.
答案1
得分: 0
只要 SizSamp 和 FoldPaste 被选中,就会发生这种情况。
End If
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 处执行相同操作。
英文:
It can happen if SizSamp and FoldPaste are checked.
If SizSamp.Value = True Then
If selectedOptions1 <> "" Then
selectedOptions1 = selectedOptions1 & " & "
End If
selectedOptions1 = selectedOptions1 & SizSamp.Caption
End If
End If
Change
End If
If SizSamp.Value = True Then
If selectedOptions1 <> "" Then
selectedOptions1 = selectedOptions1 & " & "
End If
selectedOptions1 = selectedOptions1 & SizSamp.Caption
End If
and do the same at FoldPaste.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论