I need to assign a hot key to a macro using code and I seem to be misunderstanding how it works since none of the examples I've followed online have worked for me. I'm trying to make "Ctrl-Shift-w" start MyMacro:
Private Sub HotKey()
Application.OnKey "^+w", "MyMacro"
End Sub
Sub MyMacro()
'''This is where my macro code goes
End Sub
Is there a reason why this won't work? Or is there another way I can write code for assigning a hot key? For various reasons, I can't assign a hot key by going into the "Options" tab and I can't assign a hot key upon opening a workbook.
Private Sub HotKey()
Application.OnKey "^+w", "MyMacro"
End Sub
Sub MyMacro()
'''This is where my macro code goes
End Sub
Is there a reason why this won't work? Or is there another way I can write code for assigning a hot key? For various reasons, I can't assign a hot key by going into the "Options" tab and I can't assign a hot key upon opening a workbook.