Function Key

  • Thread starter Thread starter Bradley Tom
  • Start date Start date
B

Bradley Tom

Hi there,
How to assign F9 function key to a button made by form
tools?
Can it be done without micro?
It will be simple but I don't know how to do it.
Please help me out.
Thanks a lot.

Bradley Tom
 
Can you clarify what you want?

Are you asking how to make the F9 key run a macro that's associated with a
button from the forms toolbar on a worksheet?

If yes, I think you'll need a macro.

Option Explicit
Sub mybuttonclick()
MsgBox "HI"
End Sub
Sub F9On()
Application.OnKey "{f9}", "mybuttonclick"
End Sub
Sub F9Off()
Application.OnKey "{f9}"
End Sub

The first macro is what's assigned to the button.
The second changes the behavior of F9
The third puts it back to calculate.

(And if you don't want to change the shortcut to calculate, you may want to use
a different F# key.)
 
Hi! Dave Peterson

Thanks a lot

-----Original Message-----
Can you clarify what you want?

Are you asking how to make the F9 key run a macro that's associated with a
button from the forms toolbar on a worksheet?

If yes, I think you'll need a macro.

Option Explicit
Sub mybuttonclick()
MsgBox "HI"
End Sub
Sub F9On()
Application.OnKey "{f9}", "mybuttonclick"
End Sub
Sub F9Off()
Application.OnKey "{f9}"
End Sub

The first macro is what's assigned to the button.
The second changes the behavior of F9
The third puts it back to calculate.

(And if you don't want to change the shortcut to calculate, you may want to use
a different F# key.)



--

Dave Peterson
(e-mail address removed)
.
 
Back
Top