用 下面這段程式碼:
Sub howmanychk()
For Each chk In ActiveSheet.CheckBoxes
If chk.Value = 1 Then j = j + 1
Next
MsgBox "共有【" & j & "】個勾選!", vbInformation
End Sub
結果是:
如果只統計D列一年級的勾選,可以用下面的程式碼
Sub Howmany1()
If chk.Value = 1 And Left(chk.TopLeftCell.Address, 2) = "$D" Then j = j + 1
用 下面這段程式碼:
Sub howmanychk()
For Each chk In ActiveSheet.CheckBoxes
If chk.Value = 1 Then j = j + 1
Next
MsgBox "共有【" & j & "】個勾選!", vbInformation
End Sub
結果是:
如果只統計D列一年級的勾選,可以用下面的程式碼
Sub Howmany1()
For Each chk In ActiveSheet.CheckBoxes
If chk.Value = 1 And Left(chk.TopLeftCell.Address, 2) = "$D" Then j = j + 1
Next
MsgBox "共有【" & j & "】個勾選!", vbInformation
End Sub