假设两个复选框(checkbox),个数在A1中显示。
拷贝下面代码。
Private Sub CheckBox1_Click()
Call RefreshCount(CheckBox1.Value)
End Sub
Private Sub CheckBox2_Click()
Call RefreshCount(CheckBox2.Value)
End Sub
Private Sub RefreshCount(fg As Boolean)
If Trim(Cells(1, 1).Value) = vbNullString Then
If fg Then
Cells(1, 1).Value = 1
End If
Else
If fg Then
Cells(1, 1).Value = CInt(Cells(1, 1).Value) + 1
Else
Cells(1, 1).Value = CInt(Cells(1, 1).Value) - 1
End If
End If
End Sub
迷糊!