Key behaviour

R

Rodney

Hi there,

Is there a possibilty to capture the keycode from a
worksheet. Not from a form or checkbox or related objets.
I would like to recognize from the worksheet when a <F4>
is given to execute some code.

Many thanks in advance.
 
H

Hank Scorpio

Hi there,

Is there a possibilty to capture the keycode from a
worksheet. Not from a form or checkbox or related objets.
I would like to recognize from the worksheet when a <F4>
is given to execute some code.

Many thanks in advance.

Just be aware that this will last for the length of your Excel
session, and will apply to ALL workbooks.

Sub GetKeyAndDoSomething()

'To make this line run automatically, put it in the
'Workbook_Open event in the Workbook's code module
'instead of a standard procedure like this one.

Application.OnKey "{F4}", "MyProcedure"

End Sub


Sub MyProcedure()

MsgBox "This is my procedure."

End Sub
 

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

Top