单击单元格时如何运行代码? [英] How to run code when clicking a cell?

查看:101
本文介绍了单击单元格时如何运行代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道我可以使用Worksheet_SelectionChange,但这并不能完全满足我的要求.

I'm aware that I can use Worksheet_SelectionChange but this doesn't do exactly what I want.

例如,当我用箭头键移动活动单元时,它仍将运行代码.

For example when I move the active cell with the arrow keys it will still run the code.

当我实际在单元格上单击时,如何只让它运行代码?

推荐答案

Excel应用程序的VBA无法捕获鼠标左键.有一些方法可以全局检查鼠标左键是否被按下,但是从我收集的数据来看,这似乎并不简单可靠.参见:

The left mouse click cannot be trapped with VBA for the Excel application. There are some methods to check globally if the left mouse button is pressed down but it does not seem simple and reliable from what I gather. See:

http://www.experts-exchange. com/Software/Office_Productivity/Office_Suites/MS_Office/Excel/Q_28343702.html 尚未解决(基本上与您有相同的问题)

http://www.experts-exchange.com/Software/Office_Productivity/Office_Suites/MS_Office/Excel/Q_28343702.html which is unresolved (basically the same question you have)

SelectionChange不能仅对鼠标起作用: http://excel.tips.net/T003070_Mouse_Click_Event_in_VBA.html

SelectionChange cannot only work for the mouse: http://excel.tips.net/T003070_Mouse_Click_Event_in_VBA.html

经过大量搜索之后,网上对此一无所知.这可能不是您要找的答案,但我认为您找不到想要的东西.

After lots of searching nothing on the web is conculsive about this. This may not be the answer you're looking for but I don't think you'll find what you want.

这篇关于单击单元格时如何运行代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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