问题
I would like to get the row numbers of each deleted row after or before the rows are deleted in VBA.
There is an Event BeforeDelete() but when I delete a row it is not triggered?
Is there any other events or ways I could do this?
Here's kinda what I want:
Private Sub Worksheet_BeforeDelete()
Dim i As Integer
i = ActiveCell.Row
End Sub
回答1:
The following event macro will tell you whenever an entire row is deleted or inserted:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Rows.Count = 1 And Target.Columns.Count = Columns.Count Then
MsgBox Target.Row
End If
End Sub
来源:https://stackoverflow.com/questions/49560431/how-to-catch-rows-deleted-in-excel-vba