Shortcut Key

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Would appreciate some help from the experts out there. Is there a way to invoke "Userform2.Show" using key strokes when Userform1 is currently being displayed?
 
Francis

You can use the KeyPress event:

Private Sub UserForm_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)

If KeyAscii = 6 Then 'Control+F
UserForm2.Show
End If

End Sub


--
Dick Kusleika
MVP - Excel
www.dicks-clicks.com
Post all replies to the newsgroup.

Francis Ang said:
Would appreciate some help from the experts out there. Is there a way to
invoke "Userform2.Show" using key strokes when Userform1 is currently being
displayed?
 
Thanks for you help Dick. I tried putting in the code you suggested but nothing happen when I pressed "Ctrl F" while Userform1 was being displayed. Where did I go wrong?
 
Francis

I don't know. Make sure you put the sub in the code module behind the
userform. In the VBE, right click anywhere on the userform and choose View
Code. This code does not go in a standard module.

Make sure that the code is behind the proper userform. It needs to be
behind the form that you are calling FROM, not the form that you intend to
open.

Make sure the name of the userform in the code matches the name of the
userform you want to open.

Make sure that your keyboard isn't mapped different than mine. In the
Keypress event add this line

MsgBox KeyAscii

then open the form and press Control-F (or whatever key combination you
want to use), and see what the message box says.

Dick

Francis Ang said:
Thanks for you help Dick. I tried putting in the code you suggested but
nothing happen when I pressed "Ctrl F" while Userform1 was being displayed.
Where did I go wrong?
 

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