检查是否选中了基于工作表的复选框 [英] Checking if a worksheet-based checkbox is checked

查看:159
本文介绍了检查是否选中了基于工作表的复选框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用IF子句来确定我的复选框(名为复选框1)是否已选中,以便在我的程序中继续使用。

I'm trying to use an IF-clause to determine whether my checkbox, named "Check Box 1", is checked or not, for further use in my program.

我当前的代码:

Sub Button167_Click()
 If ActiveSheet.Shapes("Check Box 1") = True Then
 Range("Y12").Value = 1
 Else
 Range("Y12").Value = 0
 End If
End Sub

这似乎不工作,但调试告诉我有一个问题

This doesn't seem to work, but the debug is telling me there is a problem with the

      ActiveSheet.Shapes("Check Box 1")

但是,我知道这个代码可以工作(即使它服务于不同的目的):

However, I know this code works (even though it serves a different purpose):

ActiveSheet.Shapes("Check Box 1").Select
With Selection
.Value = xlOn


b $ b

编辑:
如果需要更多信息,我的复选框(我的页面上有200个)位于sheet1中,名称为Demande。每个复选框都有相同的格式名称复选框...。

If more Information is necessary, My checkboxes (there are 200 on my page), are located in sheet1, by the name of "Demande". And each Checkbox is has the same formatted name of "Check Box ...".

所有的帮助将不胜感激。谢谢

All help would be appreciated. Thanks

推荐答案

Sub Button167_Click()
 If ThisWorkbook.Worksheets(1).Shapes("Check Box 1").OLEFormat.Object.Value = 1 Then
 Range("Y12").Value = 1
 Else
 Range("Y12").Value = 0
 End If
End Sub

1被选中,-4146未被选中,2是混合(灰色框)

1 is checked, -4146 is unchecked, 2 is mixed (grey box)

这篇关于检查是否选中了基于工作表的复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆