如何将Excel上的复选框链接到VBA代码 [英] how to link a checkbox on Excel to a VBA code

查看:161
本文介绍了如何将Excel上的复选框链接到VBA代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在我的Excel工作表上创建了一个复选框,使用我已左击它的设计模式,并将其命名为ChkV,我写了一个VBA代码,但是当我运行它,我得到一个消息告诉该变量未定义。

 如果ChkV.Value = True然后
'我的代码
结束如果

我没有正确标记复选框,我做错了什么?


b p $ p> 如果activesheet.Checkboxes(ChkV)= xlOn then
'您的代码
结束如果


I have created a checkbox on my Excel Work sheet, using design mode I have leftclicked it and named it ChkV, and I wrote a VBA code but when I run it I get an message telling that the variable is not defined.

    If ChkV.Value = True Then
        ' my code
    End If

Did I not label the check box correctly, what am I doing wrong ? How should I fix the mistake?

解决方案

Should it not be

If  activesheet.Checkboxes("ChkV") = xlOn Then
'your code
End If

?

这篇关于如何将Excel上的复选框链接到VBA代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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