ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Deleting rows triggers the macro :( (https://www.excelbanter.com/excel-programming/436937-deleting-rows-triggers-macro.html)

Dav1d

Deleting rows triggers the macro :(
 
My macro is working well. It inserts a row and copies formula when the
target column is selected. A beautiful thing.

The problem occurs when I (or users) try to delete an row. It inserts
another row, then another when they try to delete that one! It gets ugly
very fast.

This is the selection code:

Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
If Not Application.Intersect(Target, Range("N:N")) Is Nothing Then
Target.Offset(1).EntireRow.Insert

Can anyone suggest what I can change to avoid the problem? The target
coulum is populated from a named list.

Many thanks
David

Don Guillett

Deleting rows triggers the macro :(
 
1st line
if target.count1 then exit sub


--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Dav1d" wrote in message
...
My macro is working well. It inserts a row and copies formula when the
target column is selected. A beautiful thing.

The problem occurs when I (or users) try to delete an row. It inserts
another row, then another when they try to delete that one! It gets ugly
very fast.

This is the selection code:

Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
If Not Application.Intersect(Target, Range("N:N")) Is Nothing Then
Target.Offset(1).EntireRow.Insert

Can anyone suggest what I can change to avoid the problem? The target
coulum is populated from a named list.

Many thanks
David




All times are GMT +1. The time now is 11:45 AM.

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