Excel VBA输入密钥运行宏 [英] excel vba enter key run macro

查看:84
本文介绍了Excel VBA输入密钥运行宏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我敢肯定这很简单,但是对于我一生来说,我找不到怎么做

I'm sure this must be simple but for the life of me I can't find how to do it

如何检测在特定范围的单元格上已按下Enter键

How do I detect that the enter key has been pressed on a particular range of cell

我有一组合并的单元格($ H $ 9:$ K $ 13),基本上是一个供用户输入数字的框.一旦用户按下Enter键,我想运行一个宏(在键盘上不是num键盘)

I have a group of merged cells ($H$9:$K$13) which is basically a box which the user enters a number. I want to run a macro once the user presses enter (on the keyboard NOT the num keypad)

我找不到关于此的任何示例.我可以在文本框中找到执行此操作的示例,而在单元格中找不到

I cant find any examples on this. I can find example on doing this from a text box but not from a cell

我试过了Application.onkeys,它可以在组合键上使用,但不能在Enter键上使用(它对回车键使用波浪号,对数字键盘按ENTER键,但均无效)

I have tried Application.onkeys which works on key combinations but not on the enter key (it says tilde for enter key and ENTER for num pad but neither work)

推荐答案

您确定要检测ENTER键的按下事件吗?

Do you surely want to detect the press event of ENTER keys?

如果用户使用Tab键更改了您在帖子中记录的某些单元格的输入,您的想法如何.或由于鼠标单击而更改了选择范围,从而使单元格中的值更改了.

How do you think, if users used tab key to change the input of certain cells you noted in your post. Or selection range was changed because of mouse click leaving values in cell changed.

我有点困惑,因为使用

I'm little confused, because using Workbook.SheetChange Event you can run procedures for your purpose. Of course you can check the range changed was in the range you noted or not, in this event procedure using argument Target.

这篇关于Excel VBA输入密钥运行宏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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