Is there a way to let the function keys control a macro? For example, I want to write a program that will run a macro whenever you press F1. How would I do that?
Is there a way to let the function keys control a macro? For example, I want to write a program that will run a macro whenever you press F1. How would I do that?
See the OnKey method in help. E.g., to assign a macro to F1, use
Application.OnKey "{F1}", "MacroName"
--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
"Tha BeatMaker"
<[email protected]>
wrote in message
news:[email protected]...
>
> Is there a way to let the function keys control a macro? For
> example, I
> want to write a program that will run a macro whenever you
> press F1.
> How would I do that?
>
>
> --
> Tha BeatMaker
> ------------------------------------------------------------------------
> Tha BeatMaker's Profile:
> http://www.excelforum.com/member.php...o&userid=23998
> View this thread:
> http://www.excelforum.com/showthread...hreadid=397040
>
I have created a userform, label and macro named UserForm1, lblPress, and Functest respectively. Here is my code.
Private Sub UserForm_Initialize()
Application.OnKey "{F10}", "functest"
End Sub
----------------------------------------------------------------------
Private Sub UserForm_Terminate()
Application.OnKey "{F10}"
End Sub
----------------------------------------------------------------------
Sub functest()
Const conMsg As String = "You have pressed F10"
lblPress.Caption = conMsg
End Sub
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks