Buttons

Fire_Chief

Well-known Member
Joined
Jun 21, 2003
Messages
693
Office Version
  1. 365
Platform
  1. Windows
Is there a way I can press a number or a letter and have a sub routine run. I don't want a button on the page?

Thank You
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
You can use Ctrl+
Bring up your Macro Llist
Select Macro
Select Options
Set Key
 
Upvote 0
Be aware when you set a Macro Key it will override its original purpose so if you allocate Control+C it will run the Macro for this reason most people use Control + Shift and a key so this does not happen
 
Upvote 0
After I choose Options....

I see Editor, Editor Format, General and Docking but no where to set ket.
 
Upvote 0
depending on the version of excel you need to select Macros in 2003
it is in the tools menu and 2007 you select it from the developer tab
then you will see a list of Macro's highlight the one you want to allocate a button to and then the options key is in the lower right hand corner of the tab
 
Upvote 0
You may also try Onkey method. Run macro by just pressing D.

You may replace D with some other letter/alphabet if you wish to

In standard module...
Code:
[FONT=Courier New][COLOR=black]Option Explicit    [/COLOR][/FONT]
[FONT=Courier New][COLOR=black]Sub StartKey()[/COLOR][/FONT]
[FONT=Courier New][COLOR=black]  Application.OnKey "D", "MyProcedure"[/COLOR][/FONT]
[FONT=Courier New][COLOR=black]End Sub[/COLOR][/FONT]
[FONT=Courier New][COLOR=black]Sub EndKey()[/COLOR][/FONT]
[FONT=Courier New][COLOR=black]  Application.OnKey "D"[/COLOR][/FONT]
[FONT=Courier New][COLOR=black]End Sub[/COLOR][/FONT]
[FONT=Courier New][COLOR=black]Sub MyProcedure()[/COLOR][/FONT]
[FONT=Courier New][COLOR=black]  MsgBox "My OnKey is active", 0, vbNullString[/COLOR][/FONT]
[FONT=Courier New][COLOR=black]End Sub[/COLOR][/FONT]
[FONT=Courier New][COLOR=black]'Thisworkbook module[/COLOR][/FONT]
[FONT=Courier New][FONT=Verdana][COLOR=black]Option Explicit[/COLOR][/FONT]
[FONT=Courier New][COLOR=black]Private Sub Workbook_Activate()[/COLOR][/FONT]
[FONT=Courier New][COLOR=black]   Call StartKey[/COLOR][/FONT]
[FONT=Courier New][COLOR=black]End Sub[/COLOR][/FONT]
[FONT=Courier New][COLOR=black]Private Sub Workbook_Deactivate()[/COLOR][/FONT]
[FONT=Courier New][COLOR=black]   Call EndKey[/COLOR][/FONT]
[FONT=Courier New][COLOR=black]End Sub[/COLOR][/FONT]
[/FONT]
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,599
Messages
6,179,827
Members
452,946
Latest member
JoseDavid

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