Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Need Help with ActiveCell.EntireRow.Delete | Excel Discussion (Misc queries) | |||
Need Help with ActiveCell.EntireRow.Delete | Excel Discussion (Misc queries) | |||
delete entirerow if date more than 12months old | Excel Discussion (Misc queries) | |||
EntireRow.Delete | Excel Programming | |||
How do I delete entirerow that contains few command buttons | Excel Programming |