将多个选中复选框的值输入到单个文本框vba

将多个选中复选框的值输入到单个文本框vba,vba,excel,Vba,Excel,我有多个复选框和一个文本框。如何将所有复选框的值勾选到VBA Userform中的单个文本框? 我的表格是这样的 IIF主席: Textbox1.Value=iif(chk1,"AccountBlaBla","") & iif(chk2,"Orders","") & _ iif(chk3,"ReturningBlaBla","") IIF是一个不错的内联IF替代方案,您可以在串联中使用它。如果checkbox1的值为true,则向连接中添加一些文本,等等。您可能希望使用单独的变

我有多个复选框和一个文本框。如何将所有复选框的值勾选到VBA Userform中的单个文本框? 我的表格是这样的

IIF主席:

Textbox1.Value=iif(chk1,"AccountBlaBla","") & iif(chk2,"Orders","") & _
iif(chk3,"ReturningBlaBla","")
IIF是一个不错的内联IF替代方案,您可以在串联中使用它。如果checkbox1的值为true,则向连接中添加一些文本,等等。您可能希望使用单独的变量来组合文本,这可能更容易理解…

解决方案方法:
这将为您提供获取加厚框的值的函数,因为这是一个函数,请根据需要使用它
代码:

示例:

你的代码尝试在哪里?@ShaiRado我还在努力想办法。。我还没有任何示例代码..:(@Meedee查看此网站以帮助您前往@ShaiRado非常感谢您的链接!!!我现在就知道了!:)谢谢。。我以前没有使用过IIF,但我也会尝试使用这些代码。如果答案有用/适合您的需要,请不要忘记相应地单击有用/接受的答案:)
Option Base 1
Function Array_Ticked_Checkboxes() As String()
Dim ItemControl As Control
Dim DummyArray() As String
Dim CounterDummy As Long
    For Each ItemControl In Me.Controls
    If TypeName(ItemControl) = "CheckBox" Then ' 1. If TypeName(ItemControl) = "CheckBox"
    'you can't do both checkings at the same time because it will give error on items that are not checkboxes
    If ItemControl.Value = True Then CounterDummy = CounterDummy + 1: ReDim Preserve DummyArray(CounterDummy): DummyArray(CounterDummy) = ItemControl.Caption
    End If ' 1. If TypeName(ItemControl) = "CheckBox"
    Next ItemControl
    Array_Ticked_Checkboxes = DummyArray
End Function
Private Sub CommandButton1_Click()
Dim ArrayTickedCheckboxes() As String
Dim ItemArray As Variant
    ArrayTickedCheckboxes = Array_Ticked_Checkboxes
    On Error GoTo Err01CommandButton1_Click
    For Each ItemArray In ArrayTickedCheckboxes
    MsgBox ItemArray
    Next ItemArray
Err01CommandButton1_Click:
End Sub