Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Why xl deletes 250+ rows using worksheet_change


A simple macro to delete 1 row at a time when the value of a cell
changes now deletes 250+ rows at a time. I only want to delete the 1st
row of a worksheet when there is a change in a cell on the 1st row, then
move the following row in its place.

Private Sub Worksheet_Change(ByVal Target As Range)

Range("1:1").Select
Selection.Delete xlShiftUp
End Sub

Thanks for any help!!


--
stumanchu
------------------------------------------------------------------------
stumanchu's Profile: http://www.excelforum.com/member.php...o&userid=33793
View this thread: http://www.excelforum.com/showthread...hreadid=535662

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Why xl deletes 250+ rows using worksheet_change

When you change a cell, the Change event is called. This deletes
row 1, which is a change, so Change is called again, which
deletes row 1, which causes Change to be called again, over and
over and over. Change your code to

Application.EnableEvents = False
Range("1:1").Select
Selection.Delete xlShiftUp
Application.EnableEvents = True



--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"stumanchu"
wrote in
message
...

A simple macro to delete 1 row at a time when the value of a
cell
changes now deletes 250+ rows at a time. I only want to delete
the 1st
row of a worksheet when there is a change in a cell on the 1st
row, then
move the following row in its place.

Private Sub Worksheet_Change(ByVal Target As Range)

Range("1:1").Select
Selection.Delete xlShiftUp
End Sub

Thanks for any help!!


--
stumanchu
------------------------------------------------------------------------
stumanchu's Profile:
http://www.excelforum.com/member.php...o&userid=33793
View this thread:
http://www.excelforum.com/showthread...hreadid=535662



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Why xl deletes 250+ rows using worksheet_change


I see!! Thanks a bunch - it works!


--
stumanchu
------------------------------------------------------------------------
stumanchu's Profile: http://www.excelforum.com/member.php...o&userid=33793
View this thread: http://www.excelforum.com/showthread...hreadid=535662

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Deleting Rows - only deletes content Phil Excel Discussion (Misc queries) 2 March 12th 10 04:43 PM
Macro that deletes rows from cell containing End to end of data. Richard Excel Discussion (Misc queries) 2 July 25th 07 03:51 PM
shared file adds or deletes rows woodman Excel Discussion (Misc queries) 0 May 31st 07 04:46 PM
Help With a Loop That Deletes Rows Vecchia Excel Programming 5 November 21st 05 10:04 PM
Macro that deletes certain rows and not others Roger[_20_] Excel Programming 8 May 3rd 05 12:02 AM


All times are GMT +1. The time now is 06:40 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"