PDA

View Full Version : Solved: onchange event fired by deletion of row or adding row



CodeNinja
11-14-2012, 02:36 PM
I need to fire an alert when a user adds or deletes a row in a sheet. I figure the best way to do this is through the onchange event procedure. Is there a test to see if the user deleted or added an entire row?

Aflatoon
11-15-2012, 06:01 AM
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Rows(1).Cells.Count = Columns.Count Then
MsgBox "entire row affected"
End If
End Sub

should work.

CodeNinja
11-15-2012, 08:02 AM
That is perfect. I am marking as solved. Thanks!

GTO
11-15-2012, 08:15 AM
Hi Aflatoon :hi:

Probably of no consequence whatsoever, but just in case of an Excel 2000 user...

In 2000, the deletion of a row will get trapped, but the insertion of a row will not. (I do not know, or do not recall why this anomoly existed, just that XLD or Malcom verified it for me quite some time ago.)

Hope all is well in your corner of the world,

Mark

Aflatoon
11-15-2012, 08:25 AM
Hi Mark,
Thanks for the heads-up. However, like MS, I don't support XL 2000 any more. ;)

All cool here. Unfortunately, literally so. :)

GTO
11-15-2012, 09:40 AM
...However, like MS, I don't support XL 2000 any more. ;)


:beerchug: Ouch and ROFL!