Thread: Keypress
View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_7_] Bob Phillips[_7_] is offline
external usenet poster
 
Posts: 1,120
Default Keypress

Same as mine <g

"Greg Wilson" wrote in message
...
This is my suggestion:

'Paste to the Worksheet module
Private Sub Worksheet_Change(ByVal Target As Range)
If DisableStatus Then Exit Sub
'Your code in place of MsgBox
MsgBox "Test"
End Sub

'Paste to ThisWorkbook module
Private Sub Workbook_Activate()
With Application
.OnKey "E", "DisableWC"
.OnKey "R", "EnableWC"
End With
End Sub

Private Sub Workbook_Deactivate()
With Application
.OnKey "E"
.OnKey "R"
End With
End Sub

'Paste to a standard module
Public DisableStatus As Boolean

Sub DisableWC()
MsgBox "Worksheet_Change event disabled"
DisableStatus = True
End Sub

Sub EnableWC()
MsgBox "Worksheet_Change event enabled"
DisableStatus = False
End Sub

Regards,
Greg


"broogle" wrote:

Please help,

I have a worksheet_change event, I want to disable this event if key
"E" is pressed and enable it again if key "R" is pressed. Is it
possible? How can I do that?

Thanks