ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Hot Keys (https://www.excelbanter.com/excel-worksheet-functions/123141-hot-keys.html)

Inspector

Hot Keys
 
I have a macro that I would like to fire by hitting the 'Control 1' keys.
How do I begin?

Thanks

Nick Hodge

Hot Keys
 
Check out the Onkey method, this re-purposes the built in Excel keys

Sub test()
'Re-puposes
Application.OnKey "^1", "MyCode"
End Sub

Sub myCode()
MsgBox "It ran with Ctrl+1"
End Sub


--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
DTHIS
www.nickhodge.co.uk


"Inspector" wrote in message
...
I have a macro that I would like to fire by hitting the 'Control 1' keys.
How do I begin?

Thanks



Inspector

Hot Keys
 
Okay, so here are my 2 macros....I need the first one to be fired by 'Control
1' and the second to be fired by 'Control 2'. How would I integrate your
suggestion into this VB code? BTW I know very little about this.


Sub sortprintareaonlyp()
With ActiveSheet.Range("Print_Area")
.Sort Key1:=.Cells(2, 16), Order1:=xlDescending
ActiveSheet.PrintOut
.Sort Key1:=.Cells(2, 17), Order1:=xlAscending
End With
End Sub

Sub sortprintareaonlys()
With ActiveSheet.Range("Print_Area")
.Sort Key1:=.Cells(2, 16), Order1:=xlDescending
End With
End Sub

"Nick Hodge" wrote:

Check out the Onkey method, this re-purposes the built in Excel keys

Sub test()
'Re-puposes
Application.OnKey "^1", "MyCode"
End Sub

Sub myCode()
MsgBox "It ran with Ctrl+1"
End Sub


--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
DTHIS
www.nickhodge.co.uk


"Inspector" wrote in message
...
I have a macro that I would like to fire by hitting the 'Control 1' keys.
How do I begin?

Thanks




Nick Hodge

Hot Keys
 
Inspector

Have a third to set them, run it and they will be set.

Sub AssignKeys
With Application
.OnKeys "^1","sortprintareaonlyp"
.OnKeys "^2","sortprintareaonlys"
End With
End Sub

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
DTHIS
www.nickhodge.co.uk


"Inspector" wrote in message
...
Okay, so here are my 2 macros....I need the first one to be fired by
'Control
1' and the second to be fired by 'Control 2'. How would I integrate your
suggestion into this VB code? BTW I know very little about this.


Sub sortprintareaonlyp()
With ActiveSheet.Range("Print_Area")
.Sort Key1:=.Cells(2, 16), Order1:=xlDescending
ActiveSheet.PrintOut
.Sort Key1:=.Cells(2, 17), Order1:=xlAscending
End With
End Sub

Sub sortprintareaonlys()
With ActiveSheet.Range("Print_Area")
.Sort Key1:=.Cells(2, 16), Order1:=xlDescending
End With
End Sub

"Nick Hodge" wrote:

Check out the Onkey method, this re-purposes the built in Excel keys

Sub test()
'Re-puposes
Application.OnKey "^1", "MyCode"
End Sub

Sub myCode()
MsgBox "It ran with Ctrl+1"
End Sub


--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
DTHIS
www.nickhodge.co.uk


"Inspector" wrote in message
...
I have a macro that I would like to fire by hitting the 'Control 1'
keys.
How do I begin?

Thanks





Inspector

Hot Keys
 
Sorry for being so numb but this is what I have now and when I hit 'Control
1' I get a pop up to format cells.

Sub sortprintareaonlyp()
With ActiveSheet.Range("Print_Area")
.Sort Key1:=.Cells(2, 16), Order1:=xlDescending
ActiveSheet.PrintOut
.Sort Key1:=.Cells(2, 17), Order1:=xlAscending
End With
End Sub

Sub sortprintareaonlys()
With ActiveSheet.Range("Print_Area")
.Sort Key1:=.Cells(2, 16), Order1:=xlDescending
End With
End Sub

Sub AssignKeys()
With Application
.OnKeys "^1", "sortprintareaonlyp"
.OnKeys "^2", "sortprintareaonlys"
End With
End Sub

"Nick Hodge" wrote:

Inspector

Have a third to set them, run it and they will be set.

Sub AssignKeys
With Application
.OnKeys "^1","sortprintareaonlyp"
.OnKeys "^2","sortprintareaonlys"
End With
End Sub

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
DTHIS
www.nickhodge.co.uk


"Inspector" wrote in message
...
Okay, so here are my 2 macros....I need the first one to be fired by
'Control
1' and the second to be fired by 'Control 2'. How would I integrate your
suggestion into this VB code? BTW I know very little about this.


Sub sortprintareaonlyp()
With ActiveSheet.Range("Print_Area")
.Sort Key1:=.Cells(2, 16), Order1:=xlDescending
ActiveSheet.PrintOut
.Sort Key1:=.Cells(2, 17), Order1:=xlAscending
End With
End Sub

Sub sortprintareaonlys()
With ActiveSheet.Range("Print_Area")
.Sort Key1:=.Cells(2, 16), Order1:=xlDescending
End With
End Sub

"Nick Hodge" wrote:

Check out the Onkey method, this re-purposes the built in Excel keys

Sub test()
'Re-puposes
Application.OnKey "^1", "MyCode"
End Sub

Sub myCode()
MsgBox "It ran with Ctrl+1"
End Sub


--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
DTHIS
www.nickhodge.co.uk


"Inspector" wrote in message
...
I have a macro that I would like to fire by hitting the 'Control 1'
keys.
How do I begin?

Thanks





David Billigmeier

Hot Keys
 
Try:

<Tools<Macro<Macros...
Select your sub
Click "Options"
Enter your keyboard shortcut

--
Regards,
Dave


"Inspector" wrote:

I have a macro that I would like to fire by hitting the 'Control 1' keys.
How do I begin?

Thanks


Nick Hodge

Hot Keys
 
Inspector

Did you run (ToolsMacrosMacros...run the AssignKeys code. Do this first
and you should find the keys re-purposed

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
DTHIS
www.nickhodge.co.uk


"Inspector" wrote in message
...
Sorry for being so numb but this is what I have now and when I hit
'Control
1' I get a pop up to format cells.

Sub sortprintareaonlyp()
With ActiveSheet.Range("Print_Area")
.Sort Key1:=.Cells(2, 16), Order1:=xlDescending
ActiveSheet.PrintOut
.Sort Key1:=.Cells(2, 17), Order1:=xlAscending
End With
End Sub

Sub sortprintareaonlys()
With ActiveSheet.Range("Print_Area")
.Sort Key1:=.Cells(2, 16), Order1:=xlDescending
End With
End Sub

Sub AssignKeys()
With Application
.OnKeys "^1", "sortprintareaonlyp"
.OnKeys "^2", "sortprintareaonlys"
End With
End Sub

"Nick Hodge" wrote:

Inspector

Have a third to set them, run it and they will be set.

Sub AssignKeys
With Application
.OnKeys "^1","sortprintareaonlyp"
.OnKeys "^2","sortprintareaonlys"
End With
End Sub

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
DTHIS
www.nickhodge.co.uk


"Inspector" wrote in message
...
Okay, so here are my 2 macros....I need the first one to be fired by
'Control
1' and the second to be fired by 'Control 2'. How would I integrate
your
suggestion into this VB code? BTW I know very little about this.


Sub sortprintareaonlyp()
With ActiveSheet.Range("Print_Area")
.Sort Key1:=.Cells(2, 16), Order1:=xlDescending
ActiveSheet.PrintOut
.Sort Key1:=.Cells(2, 17), Order1:=xlAscending
End With
End Sub

Sub sortprintareaonlys()
With ActiveSheet.Range("Print_Area")
.Sort Key1:=.Cells(2, 16), Order1:=xlDescending
End With
End Sub

"Nick Hodge" wrote:

Check out the Onkey method, this re-purposes the built in Excel keys

Sub test()
'Re-puposes
Application.OnKey "^1", "MyCode"
End Sub

Sub myCode()
MsgBox "It ran with Ctrl+1"
End Sub


--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
DTHIS
www.nickhodge.co.uk


"Inspector" wrote in message
...
I have a macro that I would like to fire by hitting the 'Control 1'
keys.
How do I begin?

Thanks






Inspector

Hot Keys
 
Perfect! thank you!!!

"David Billigmeier" wrote:

Try:

<Tools<Macro<Macros...
Select your sub
Click "Options"
Enter your keyboard shortcut

--
Regards,
Dave


"Inspector" wrote:

I have a macro that I would like to fire by hitting the 'Control 1' keys.
How do I begin?

Thanks


CLR

Hot Keys
 
Hi David...........

I tried this several times with different Excel files (XL97, SR2), and each
time I got a complete Excel crash...........

It did work in XP tho.............

Vaya con Dios,
Chuck, CABGx3



"David Billigmeier" wrote:

Try:

<Tools<Macro<Macros...
Select your sub
Click "Options"
Enter your keyboard shortcut

--
Regards,
Dave


"Inspector" wrote:

I have a macro that I would like to fire by hitting the 'Control 1' keys.
How do I begin?

Thanks



All times are GMT +1. The time now is 03:51 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com