Shortcut key to open a UserForm

phantom1975

MrExcel MVP
Joined
Jun 3, 2002
Messages
3,962
I would like a UserForm to pop up when CTL + H is pressed on a particular sheet only. Any suggestions?
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Hi,

The easiest way would be to assign your macro to Ctrl H as normal and then check the name of the sheet before your form is shown. If the active sheet is the right one then the form will be shown e.g.

If ActiveSheet.Name = "The sheet" Then UserForm1.Show
 
Upvote 0
Try the following setup:

'Place these two macros in the ThisWorkbook module
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Application.OnKey "^h"
End Sub

Private Sub Workbook_Open()
Application.OnKey "^h", "LoadForm"
End Sub

'Place this macro in a standard module, module1
Sub LoadForm()
If ActiveSheet.Name = "Sheet1" Then UserForm1.Show
End Sub

This code will only work once you have saved and reopened your workbook. The code will show userform1 when CTRL+h is pressed on Sheet1.

Note: CTRL+h will do nothing on the rest of the sheets.
 
Upvote 0
That's pretty much what I thought. I wasn't sure if there was a way to code it in the UserForm itself.
 
Upvote 0
This worked for me. I was using function keys so I used "{F3}" instead of the "^h" and it worked great.
Thanks,
Kevin
 
Upvote 0

Forum statistics

Threads
1,226,362
Messages
6,190,523
Members
453,611
Latest member
JRM59

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top