Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
how do i delete rows when cells meet certain criteria?
I want to delete rows 3 - 5 if the value in column b (of any of the respective rows) is zero. Below is the code that I am using but it is not working. It is leaving one of the "zero rows" in place (it is only deleting two of the rows when all three should be deleted). Any help would be greatly appreciated. Dim myRng As Range Dim zerocell As Range Set myRng = Range("b3:b5") For Each zerocell In myRng If zerocell.Text = "0" Then zerocell.EntireRow.Delete End If Next I've also tried this (and I have the same problem): Dim myRng As Range Dim zerocell As Range Set myRng = Range("b3:b5") For Each zerocell In myRng If zerocell = 0 Then zerocell.EntireRow.Delete End If Next _________________ Thanks, TB -- Tbal ------------------------------------------------------------------------ Tbal's Profile: http://www.excelforum.com/member.php...o&userid=25317 View this thread: http://www.excelforum.com/showthread...hreadid=395819 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
how do i delete rows when cells meet certain criteria?
if application.countif(Range("B3:B5"),0) 0 then
rows(3).Resize(3).Delete End if -- Regards, Tom Ogilvy "Tbal" wrote in message ... I want to delete rows 3 - 5 if the value in column b (of any of the respective rows) is zero. Below is the code that I am using but it is not working. It is leaving one of the "zero rows" in place (it is only deleting two of the rows when all three should be deleted). Any help would be greatly appreciated. Dim myRng As Range Dim zerocell As Range Set myRng = Range("b3:b5") For Each zerocell In myRng If zerocell.Text = "0" Then zerocell.EntireRow.Delete End If Next I've also tried this (and I have the same problem): Dim myRng As Range Dim zerocell As Range Set myRng = Range("b3:b5") For Each zerocell In myRng If zerocell = 0 Then zerocell.EntireRow.Delete End If Next _________________ Thanks, TB -- Tbal ------------------------------------------------------------------------ Tbal's Profile: http://www.excelforum.com/member.php...o&userid=25317 View this thread: http://www.excelforum.com/showthread...hreadid=395819 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Sum rows if muliple cells meet criteria but not others | Excel Discussion (Misc queries) | |||
Formula/Macro to delete rows that do not meet criteria from a list? | Excel Worksheet Functions | |||
Delete data in cells that don't meet criteria | New Users to Excel | |||
Delete Rows where cells does not meet criteria | Excel Worksheet Functions | |||
Excel 2000 VBA - Delete Rows That Meet Criteria | Excel Programming |