RightClick Range

J

John

Hi there,

I've added a right click popup menu to a range ("Orders" = A15:E40) that
works fine (bar my other FaceID problem - see "FaceID not available" post
earlier today).

The problem is that if I right click on a row or column header the popup,
pops up which means I loose the standard context menu. Is there an
alternative to the Intersect function that would only detect a cell that's
in the range rather than a whole row that happens to run through the range?

Thanks in advance

John


Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As
Boolean)
If Not Intersect(Range("Orders"), Target) Is Nothing Then
CommandBars("JohnsPopup").ShowPopup
Cancel = True
End If
End Sub
 
J

Jim Cone

I'm guessing there is a lot of code out there with the same problem.
Probably some of mine too.
This seems to work...

Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean)
If Not Target.Rows.Count = Me.Rows.Count Then
If Not Intersect(Range("Orders"), Target) Is Nothing Then
CommandBars("JohnsPopup").ShowPopup
Cancel = True
End If
End If
End Sub
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware



"John" <[email protected]>
wrote in message
Hi there,
I've added a right click popup menu to a range ("Orders" = A15:E40) that
works fine (bar my other FaceID problem - see "FaceID not available" post
earlier today).
The problem is that if I right click on a row or column header the popup,
pops up which means I loose the standard context menu. Is there an
alternative to the Intersect function that would only detect a cell that's
in the range rather than a whole row that happens to run through the range?
Thanks in advance
John


Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As
Boolean)
If Not Intersect(Range("Orders"), Target) Is Nothing Then
CommandBars("JohnsPopup").ShowPopup
Cancel = True
End If
End Sub
 
J

John

Hi Jim,

Thanks very much for your reply. Prompted by your example I've decided to
go for:

If Target.Columns.Count = 1 And Target.Rows.Count = 1 Then

as that seems ok for my purpose.

Thanks for the workaround.

Best regards

John
 
G

Gary Keramidas

here's what i use, not saying it's the best way, but works for me

If Target.Count = 1 Then
If Not Intersect(Target, Columns("e")) Is Nothing Then
If Worksheets("call report").ProtectContents = True Then
 
J

John

Thanks Gary. I hadn't thought about just using Target.Count.

Yet another way! Thanks again.

John
 
G

Gary Keramidas

and i use the protectcontents = true so it only works when the sheet's
protected. if it's unprotected, the right click context menu is displayed
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top