在EXCEL里面,应用VBA功能的具体操作:

我想选中打钩的时候它会显示相应的文字在特定的单元格中!但是打钩后再点多次没有勾后就变空!!
请问如何操作~?

四个选项都是显示在同一单元格吗?
这是复选框,可多选的,怎么判定呢?
你是单选还是复选?
Private Sub CheckBox1_Click()
If CheckBox1.Value = True Then
Range("A11") = CheckBox1.Caption
Else
Range("A11").ClearContents
End If
End Sub

Private Sub CheckBox2_Click()
If CheckBox2.Value = True Then
Range("A12") = CheckBox2.Caption
Else
Range("A12").ClearContents
End If
End Sub
Private Sub CheckBox3_Click()
If CheckBox3.Value = True Then
Range("A13") = CheckBox3.Caption
Else
Range("A13").ClearContents
End If
End Sub
Private Sub CheckBox4_Click()
If CheckBox4.Value = True Then
Range("A14") = CheckBox4.Caption
Else
Range("A14").ClearContents
End If
End Sub
'以上为复选情况,以下为单选情况
Private Sub OptionButton1_Click()
If OptionButton1.Visible = True Then
Range("A10") = OptionButton1.Caption
End If
End Sub
Private Sub OptionButton2_Click()
If OptionButton1.Visible = True Then
Range("A10") = OptionButton2.Caption
End If
End Sub
Private Sub OptionButton3_Click()
If OptionButton1.Visible = True Then
Range("A10") = OptionButton3.Caption
End If
End Sub
Private Sub OptionButton4_Click()
If OptionButton1.Visible = True Then
Range("A10") = OptionButton4.Caption
End If
End Sub
温馨提示:答案为网友推荐,仅供参考
第1个回答  2010-12-21
主要是用"If CheckBox1.Value = True then" 来判断是否被选择,如果被选择,则显示文字,否则为空值。

Private Sub CheckBox1_Click()
If CheckBox1.Value = True Then
ActiveSheet.Range("a10") = CheckBox1.Caption
Else
ActiveSheet.Range("a10") = ""
End If

End Sub

Private Sub CheckBox2_Click()
If CheckBox2.Value = True Then
ActiveSheet.Range("b10") = CheckBox2.Caption
Else
ActiveSheet.Range("b10") = ""
End If
End Sub

Private Sub CheckBox3_Click()
If CheckBox3.Value = True Then
ActiveSheet.Range("c10") = CheckBox3.Caption
Else
ActiveSheet.Range("c10") = ""
End If
End Sub

Private Sub CheckBox4_Click()
If CheckBox4.Value = True Then
ActiveSheet.Range("d10") = CheckBox4.Caption
Else
ActiveSheet.Range("d10") = ""
End If
End Sub

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网