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

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

问题描述

当我在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.

推荐答案

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

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.

在这里Return指定密钥,而get_detail是过程名称.

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

现在,只要您按 Enter 按钮,此工作表中的内容就会被调用.

Now within this sheet whenever you press Enter button the assigned macro will be called.

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

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