Re: assign onkey to 1 worksheet

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Hi short_n_curly,

short_n_curly wrote:
marco recorder allows you to record an onkey macro suck as on key
CTRL+t execute procedure however i have a workbook with 80+
worksheets and only want the onkey command to work on certain sheets,
can this command be assigned into the code i any particular work***
if so how?
i know that the command is application.onkey "^{t}" for the above
onkey command but this does not seem to work when i enter it into vba
cose for a particular work*** please advise thanks

Not directly. But in the procedure you assign to Ctrl+t via OnKey, you can check the Active*** to see if it matches the *** you're targeting:


Sub startit()
   Application.OnKey "^{t}", "test"
End Sub

Sub test()
   If ActiveSheet Is Sheet1 Then
       MsgBox Active***.Name
   End If
End Sub

Sub endit()
   Application.OnKey "^{t}"
End Sub

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]

.


Quantcast