3

需要在 excel 2010 的下拉列表中创建一个复选框。已经尝试创建一个列表框并选择了 multiselectExtended 选项,但这不符合我们的目的。

附加的所需功能示例:

样本](http://i.stack.imgur.com/oxoAD.jpg)![样本

4

2 回答 2

6

解决了!

检查链接以获取解决方案。

您可以在工作表上添加一个活动表单列表框并启用多选。

让我知道你的想法。

于 2013-05-06T14:03:14.697 回答
3

我认为这样做的唯一方法是创建一个自定义对话框。我希望以下内容足够清楚。

  1. 添加对话框:

    在此处输入图像描述

  2. 添加列表框:

    在此处输入图像描述

  3. 将数据添加到工作表并在列表框中引用它:

    在此处输入图像描述

  4. 在工作表中添加一个按钮:

    在此处输入图像描述

  5. 在 VBA 中添加一个模块并添加以下代码:

    Public diag As Object 'the dialog box
    
    'this code is assigned to the button on the sheet
    Sub Button3_Click()
        Set diag = DialogSheets("Dialog1") 'define the dialog box
        diag.Show 'sow the dialog box
    End Sub
    
    'to be assigned to the "OK" button in the dialog
    Sub Button2_Click()
    
        ' finds selected items
        Dim Msg As String, i As Integer
        Msg = ""
        With diag.ListBoxes("List Box 5")
            For i = 1 To .ListCount
                If .Selected(i) Then
                    Msg = Msg & .List(i) & ";"
                End If
            Next i
        End With
    
        'set the cell the values as needed
        Worksheets("Sheet1").Range("A1") = Msg
    End Sub
    
于 2013-05-06T08:53:54.833 回答