使用VBA获取Excel中所有复选框的值

Man*_*noj 5 checkbox excel vba excel-vba

我使用以下代码将多个复选框添加到excel表programaticaly:

With ActiveSheet.CheckBoxes.Add(rCell.Left, rCell.Top, rCell.Width, rCell.Height)
        .Interior.ColorIndex = xlNone
        .Caption = ""
End With
Run Code Online (Sandbox Code Playgroud)

现在我需要一个代码来解析工作表中存在的所有复选框并获取它们的值(true或false)以及它们所在的单元格.这该怎么做?

谢谢...

sys*_*ich 6

Sub Add_CheckBoxes()

With ActiveSheet.CheckBoxes.Add(ActiveCell.Left, ActiveCell.Top, ActiveCell.Width, ActiveCell.Height)
    .Interior.ColorIndex = xlNone
    .Caption = ""
End With

For Each chk In ActiveSheet.CheckBoxes
    If chk Then MsgBox "Checked"
Next
End Sub
Run Code Online (Sandbox Code Playgroud)