PC Review


Reply
Thread Tools Rate Thread

Deleting rows triggers the macro :(

 
 
Dav1d
Guest
Posts: n/a
 
      2nd Dec 2009
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
 
Reply With Quote
 
 
 
 
Don Guillett
Guest
Posts: n/a
 
      2nd Dec 2009
1st line
if target.count>1 then exit sub


--
Don Guillett
Microsoft MVP Excel
SalesAid Software
(E-Mail Removed)
"Dav1d" <(E-Mail Removed)> wrote in message
news:2E172B45-DE55-465D-985F-(E-Mail Removed)...
> 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


 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro for deleting rows and serialising the remaing rows Srinivasulu Bhattaram Microsoft Excel Programming 2 13th Nov 2008 01:32 PM
Macro for deleting rows and serialising the remaing rows Srinivasulu Bhattaram Microsoft Excel Setup 1 12th Nov 2008 06:05 PM
Macro for deleting rows and serialising the remaing rows Srinivasulu Bhattaram Microsoft Excel Worksheet Functions 1 12th Nov 2008 01:39 PM
Macro for deleting rows and serialising the remaing rows Srinivasulu Bhattaram Microsoft Excel Discussion 1 12th Nov 2008 01:32 PM
Macro deleting specified rows Snoopy Microsoft Excel Charting 0 15th Feb 2006 12:56 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:29 PM.