Hot Key

  • Thread starter Thread starter Bugsy
  • Start date Start date
B

Bugsy

Hey
Does anyone know how I can assign a macro be performed when F9 is
clicked ?
 
Busgy,

Use the OnKey method. Run this once (perhaps put it in the Workbook_Open
handler or something):

Application.OnKey "{F9}", "MySub"

Now when F9 is pressed, it'll run MySub. Note that this is for any open
workbooks, not just the one that ran the macro. Also, it will remain in
effect when you close the workbook, and if F9 is pressed then, it'll reopen
the workbook containing MySub. You can reset the F9 key with:

Application.OnKey "{F9}", ""

which works nicely in the Workbook_BeforeClose event handler.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top