ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Which Events Fire When I Delete A Row, and How Many Times? (https://www.excelbanter.com/excel-programming/310675-events-fire-when-i-delete-row-how-many-times.html)

Alan

Which Events Fire When I Delete A Row, and How Many Times?
 

Hi All,

When I delete a complete row in a worksheet, which events are firing,
and more importantly, do they fire once for the deletion of the row,
or do they fire 256 times, once for the deletion of each cell in the
row?

What if I delete two rows? Do they fire once, for the deletion of the
range, twice being once for each row, or 512 times being once for each
cell?

Thanks,

Alan.




Rob Bovey

Which Events Fire When I Delete A Row, and How Many Times?
 
Hi Alan,

The Worksheet_Change event fires in Excel 2000 and higher (but not in
Excel 97) when you delete rows on a worksheet. It fires one time, regardless
of how many rows you delete. The Target argument to the event passes you the
address of the rows that were deleted.

The change event fires for lots of other reasons as well, so it's quite
difficult to sort out row deletions from other actions that triggered the
change event. The simplest, although by no means foolproof, method is to
determine if the Target address returned by the change event refers to an
entire row.

--
Rob Bovey, MCSE, MCSD, Excel MVP
Application Professionals
http://www.appspro.com/

* Please post all replies to this newsgroup *
* I delete all unsolicited e-mail responses *


"Alan" wrote in message
...

Hi All,

When I delete a complete row in a worksheet, which events are firing,
and more importantly, do they fire once for the deletion of the row,
or do they fire 256 times, once for the deletion of each cell in the
row?

What if I delete two rows? Do they fire once, for the deletion of the
range, twice being once for each row, or 512 times being once for each
cell?

Thanks,

Alan.






Alan

Which Events Fire When I Delete A Row, and How Many Times?
 
"Rob Bovey" wrote in message
...

Hi Alan,

The Worksheet_Change event fires in Excel 2000 and higher (but
not in Excel 97) when you delete rows on a worksheet. It fires one
time, regardless of how many rows you delete. The Target argument to
the event passes you the address of the rows that were deleted.

The change event fires for lots of other reasons as well, so

it's
quite difficult to sort out row deletions from other actions that
triggered the change event. The simplest, although by no means
foolproof, method is to determine if the Target address returned by
the change event refers to an entire row.

--
Rob Bovey, MCSE, MCSD, Excel MVP
Application Professionals
http://www.appspro.com/


Thanks Rob,

That's great - much apprciated.

I had not realised that I could have worked that out for myself by
trapping and returning the Target address.

Regards,

Alan.




All times are GMT +1. The time now is 05:25 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com