Stop right click menu showing after macro has run

Chewyhairball

Active Member
Joined
Nov 30, 2017
Messages
312
Office Version
  1. 365
Platform
  1. Windows
Hi guys

I had a bit of code that when i right clicked on a cell in a range the right click menu showed up with some of my own links to macros.

I decided i would rather have a popup menu show up when i right click so made the adjustments and it works fine....except for once i have made my selection and run the macro the 'standard'
right-click menu shows up.

Is there a way i can stop it doing this after i have run my chosen macro from the popup menu.

thanks

VBA Code:
Private Sub Workbook_SheetBeforeRightClick(ByVal Sh As Object, ByVal Target As Range, Cancel As Boolean)

Dim NameColumn As Range
Set NameColumn = Range("d8:d50")

If Not Application.Intersect(Target, NameColumn) Is Nothing Then
Call CreatePopUpMenu2

End If

End Sub
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Hi there

Does the following work... Untested seeing as I do not have the code for CreatePopUpMenu...

VBA Code:
Private Sub Workbook_SheetBeforeRightClick(ByVal Sh As Object, ByVal Target As Range, Cancel As Boolean)
    Cancel = TRUE
    Dim NameColumn  As Range
    Set NameColumn = Range("d8:d50")
    If Not Application.Intersect(Target, NameColumn) Is Nothing Then
        Call CreatePopUpMenu2
    End If
End Sub
 
Upvote 0
Hi there

Does the following work... Untested seeing as I do not have the code for CreatePopUpMenu...

VBA Code:
Private Sub Workbook_SheetBeforeRightClick(ByVal Sh As Object, ByVal Target As Range, Cancel As Boolean)
    Cancel = TRUE
    Dim NameColumn  As Range
    Set NameColumn = Range("d8:d50")
    If Not Application.Intersect(Target, NameColumn) Is Nothing Then
        Call CreatePopUpMenu2
    End If
End Sub
thanks Jimmypop. I added cancel=true to the end of the code and it worked :)
 
Upvote 0

Forum statistics

Threads
1,224,833
Messages
6,181,242
Members
453,026
Latest member
cknader

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top