delete row when Worksheet_BeforeRightClick is active

robertvdb

Active Member
Joined
Jan 10, 2021
Messages
327
Office Version
  1. 2016
Platform
  1. Windows
I want to delete some rows in my Sheet, however - because Worksheet_BeforeRightClick is active - a Userform pops up.

Can I temporarily disable this event, when rightclicking on the row number at the left ?
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
You can make the original right-click menu appear when you select some rows (entire rows) by re-coding your Private Sub Worksheet_BeforeRightClick event subroutine in the way shown in this example.

Original:
VBA Code:
Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean)
'Original code
    MsgBox "Hello World!"
    Application.SendKeys ("{ESC}")
End Sub

Modified:
VBA Code:
Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean)
    Dim rngTmp As Range

    Set rngTmp = Selection.EntireRow
    If Target.Address <> rngTmp.Address Then
        'Original code
        MsgBox "Hello World!"
        Application.SendKeys ("{ESC}")
    Else
        '
        'Nothing happens, normal menu appears.
        '
    End If
End Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,215,295
Messages
6,124,103
Members
449,142
Latest member
championbowler

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