delete row if row,Col C value is "L" and next column value is zero

banana99

New Member
Joined
Mar 13, 2013
Messages
35
Hi, I can't seem to figure this one out. I think I'm close, but it just seems to keep deleting each row and will not exit the loop if the first condition is false. Thanks!
Code:
     With ActiveSheet
                .Select
                ViewMode = ActiveWindow.View
                ActiveWindow.View = xlNormalView
                .DisplayPageBreaks = False
                Firstrow = .UsedRange.Cells(1).Row
                Lastrow = .UsedRange.Rows(.UsedRange.Rows.Count).Row
                For Lrow = Lastrow To Firstrow Step -1
                    With .Cells(Lrow, "C")
                        If Not IsError(.Value) Then
                        
                            If .Value = "L" & ActiveCell.Offset(0, 1).Select = 0 Then .EntireRow.Delete
                        Else: End If
                    End With
                Next Lrow
            End With
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Code:
Sub test()
Dim LastRow, i As Long
LastRow = ActiveSheet.Range("C" & Rows.Count).End(xlUp).Row
For i = 1 To LastRow
If ActiveSheet.Range("C" & i).Value = "l" Then

If ActiveSheet.Range("D" & i).Value = "0" Then

Rows(i).Delete
i = i - 1
i = i + 1
i = i - 1

End If

End If
Next
End Sub
 
Upvote 0
Thanks sky, I think this almost does it, but I need to look for a string "L" for column C and looking for Column D same row with value of zero, if then and only then delete that row. Column C must contain "L" first, then if D same row is zero then delete.
 
Upvote 0
Code:
Sub xnx()
Dim i, s
s = Chr(30)
For i = Cells.SpecialCells(11).Row To 1 Step -1
    If Cells(i, "C") & s & Cells(i, "D") = "L" & s & 0 Then Rows(i).Delete
Next
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,808
Messages
6,121,681
Members
449,048
Latest member
81jamesacct

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top