Excel VBA:分配键盘快捷键以运行程序 [英] Excel VBA: Assign keyboard shortcut to run procedure

查看:656
本文介绍了Excel VBA:分配键盘快捷键以运行程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在VBA编辑器中按F5时,我总是希望运行我的Sub Skynet()过程。有没有办法为此过程分配键盘快捷方式。

When I press F5 in the VBA editor I would always like to run my "Sub Skynet()" procedure. Is there any way to assign a keyboard shortcut to this procedure.

推荐答案

要将键盘键分配到工作表上的按钮,您可以使用此代码,只需将此代码复制到包含按钮的工作表。

这里返回指定键, get_detail 是程序名称。

For assigning a keyboard key to button on the sheet you can use this code, just copy this code to the sheet which contain the button.
Here Return specifies the key and get_detail is the procedure name.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

Application.OnKey "{RETURN}", "get_detail"

End Sub

现在从表格中,只要按下按钮,分配的宏将被调用。

now from the sheet whenever u press enter button assigned macro will be called.

这篇关于Excel VBA:分配键盘快捷键以运行程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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