View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Peter T Peter T is offline
external usenet poster
 
Posts: 5,600
Default How to Capture right click Delete/Insert on Excel

Add a class module named Class1

''''' code in a normal module

Dim cCellDel As Class1

Sub SetUp()

Set cCellDel = New Class1
Set cCellDel.btn = CommandBars("Cell").FindControl(ID:=292) '

End Sub

Sub CheckDelRow()
Dim s As String

If cCellDel.RowIsDel(s) Then
' handle deleted
End If

End Sub

'''' code in class named Class1
Public WithEvents btn As CommandBarButton
Private mrCurRow As Range
Private msCurRowAddr As String

Private Sub btn_Click(ByVal Ctrl As Office.CommandBarButton, _
CancelDefault As Boolean)
Set mrCurRow = Selection.EntireRow
msCurRowAddr = mrCurRow.Address
Application.OnTime Now, "CheckDelRow"
End Sub
Public Function RowIsDel(Optional sRowAddr As String) As Boolean

On Error Resume Next
sRowAddr = mrCurRow.Address
If Not mrCurRow Is Nothing And Err.Number Then
MsgBox msCurRowAddr & " deleted"
RowIsDel = True
On Error Resume Next
sRowAddr = msCurRowAddr
End If
Set mrCurRow = Nothing
msCurRowAddr = ""

End Function

Run Setup then try rt-click Cell delete rows

Regards,
Peter T



"Gummadi" wrote in message
...
Hi,

I wanted to know how do we capture the right click Delete/Insert event in
Excel.

This is not same as where we select a row or column and then right click
and
select Insert/Delete. I am able to capture that event.

I wanted to know about the event when we right click on a cell, and the
select Delete/Insert and then Select option "Entire Row" or "Entire
Column".
This is what i want to capture.

Can someone please help me with this?

Thanks,

Gummadi