Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
guy guy is offline
external usenet poster
 
Posts: 6
Default How to fix cell.entirerow.delete?

I am checking cells in a column for a value and when found I do cell.entirerow.delete but my for
each loop must be messing up because some rows are skipped. How done?

for each mycell in myrange
if mycell.value = "delete" then
mycell.entirerow.delete
end if
next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 575
Default How to fix cell.entirerow.delete?

Guy,

you are messing up the range definition with each delete. You need to work
down from the end of the range. e.g.

lRows = MyRange.Rows.Count
For lCounter = lRows to 1 Step -1
if MyRange(lCounter,1).Value = "delete" Then _
MyRange(lCounter,1).EntireRow.Delete
Next lCounter

Robin Hammond
www.enhanceddatasystems.com

"guy" wrote in message
...
I am checking cells in a column for a value and when found I do
cell.entirerow.delete but my for
each loop must be messing up because some rows are skipped. How done?

for each mycell in myrange
if mycell.value = "delete" then
mycell.entirerow.delete
end if
next



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
Need Help with ActiveCell.EntireRow.Delete Ayo Excel Discussion (Misc queries) 4 July 20th 08 11:07 AM
Need Help with ActiveCell.EntireRow.Delete Ayo Excel Discussion (Misc queries) 8 July 19th 08 04:45 PM
delete entirerow if date more than 12months old flow23 Excel Discussion (Misc queries) 1 May 25th 06 03:32 PM
EntireRow.Delete Steph[_3_] Excel Programming 14 January 21st 05 10:31 PM
How do I delete entirerow that contains few command buttons John[_91_] Excel Programming 1 November 22nd 04 05:32 PM


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

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

About Us

"It's about Microsoft Excel"