Run code before "delete row" using Workbook_SheetBeforeRightClick

cgcamal

Active Member
Joined
May 2, 2007
Messages
472
Hi to all,

I'm trying to execute a Macro (Macro1) if I do Right Click over a cell and I select
from the contextual menu the option "Delete-->Entire Row".

Below in Pseudo code what I'm trying (In red what I don't know how to say to Excel in VBA code):

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

SelectRow = Target.row

If [COLOR=Red]"Delete Entire Row option" Is selected[/COLOR] Then
   [COLOR=Green] 'Before delete entire row[/COLOR]
     Run Macro1
   [COLOR=Green] 'After Run Macro1 continue the execution of delete entire row[/COLOR]
End If
    
End Sub
How can I do this?

PS: I have a "Workbook_SheetChange" in the same ThisWorkbook module, only if matters for this new event I want to monitor.

Many thanks in advance for any help.

Regards.
 
Last edited:

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes

Forum statistics

Threads
1,224,552
Messages
6,179,484
Members
452,917
Latest member
MrsMSalt

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