需要在excel 2010的下拉列表中创建一个复选框。我们已尝试创建一个列表框并选择了multiselectExtended选项,但这并不符合我们的目的。
附加所需功能的示例:
答案 0 :(得分:6)
答案 1 :(得分:3)
我认为唯一的方法是创建自定义对话框。我希望以下内容足够明确。
添加对话框:
添加一个列表框:
将数据添加到工作表并在列表框中引用它:
在工作表上添加一个按钮:
在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