Hello,
I am trying to remove rows if a certain condition is met. More specifically if the row has no value ie only zero the the row should be removed. I am using the countif function to check if the row only has zeros (and if it does then removing it), in the worksheet the formula looks like this:
COUNTIF(D25:X25;"<>0") ie any cell that renders the amount zero should be removed.
I am toying with the following code but I does not work..
Code
Sub RowDelete()
Dim Lrow As Long
Dim i As Long
Dim Data As Range
Set Data = Range("D2:Y4595")
Lrow = Data.Rows.Count
Lrow = Lrow + Data.Row - 1
Application.ScreenUpdating = False
For i = Lrow To 1 Step -1
If Application.WorksheetFunction.CountIf(Rows(i), "<>0") = 0 Then
Rows(i).Delete
End If
Next i
Application.ScreenUpdating = True
End Sub
Display More
Anyone has a clue what I am doing wrong?