View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
patrick molloy patrick molloy is offline
external usenet poster
 
Posts: 391
Default Before Right Click event

You can't stop the selection change event firing without
using
Application.EnableEvents = False
However, as the method implies, it stops all events.

What you can do though, is to set a boolean that stops
the selection change code from running...

Option Explicit
Private bStop As Boolean
Private Sub Worksheet_BeforeRightClick(ByVal Target As
Range, Cancel As Boolean)
bStop = Not bStop
Range("A1")= bstop
MsgBox "BeforeRightClick - Flag is " & bStop
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As
Range)
If Not bStop Then
MsgBox "SelectionChange"
End If
End Sub

each time you select a cell, the selection change fires.
If you right clight, you'll set the flag. selecting
another cell won't show the selection change message.
right click will reset th eflag, and changing cells will
show the message again. As an indicator, the right-click
event also places the flag value in cell A1


HTH
Patrick Molloy
Microsoft Excel MVP




-----Original Message-----
Hello,

The BeforeRightClick event first fires the

SelectionChange event. I
dont want the code in Worksheet_SelectionChange to run on
BeforeRightClick. Is there a way not to run the
worksheet_SelectionChange on right click ?

Thanks in advance.


---
Message posted from http://www.ExcelForum.com/

.