在excel 2010的下拉列表中创建一个复选框

时间:2013-05-06 07:32:57

标签: excel excel-vba excel-formula excel-2010 vba

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

附加所需功能的示例:

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

2 个答案:

答案 0 :(得分:6)

解决!

检查解决方案的this链接。

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

让我知道你的想法。

答案 1 :(得分:3)

我认为唯一的方法是创建自定义对话框。我希望以下内容足够明确。

  1. 添加对话框:

    enter image description here

  2. 添加一个列表框:

    enter image description here

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

    enter image description here

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

    enter image description here

  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