tropics123
Board Regular
- Joined
- May 11, 2016
- Messages
- 85
Hi, looking for some help to take this macro a step further. An illustration below but this is not exact because my sheet will vary with different number of rows daily.
What I'm trying to do: If column E is "0" then delete entire row but if column B has "RK003" then do not delete that row, even if column E has the value "0". My macro can only do the first half of what needs to be done but the second half (in orange font), I don't know how to do. I appreciate your help!
With ActiveSheet
.AutoFilterMode = False
With Range("E1", Range("E" & Rows.Count).End(xlUp))
.AutoFilter 1, "0"
On Error Resume Next
.Offset(1).SpecialCells(12).EntireRow.Delete
End With
.AutoFilterMode = False
End With
End Sub
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]column A[/TD]
[TD]column B[/TD]
[TD]column C[/TD]
[TD]column D[/TD]
[TD]Column E[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]RK001[/TD]
[TD][/TD]
[TD][/TD]
[TD]0[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]RK003[/TD]
[TD][/TD]
[TD][/TD]
[TD]0[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]RK005[/TD]
[TD][/TD]
[TD][/TD]
[TD]687[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]RK008[/TD]
[TD][/TD]
[TD][/TD]
[TD]0[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]RK003[/TD]
[TD][/TD]
[TD][/TD]
[TD]0[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]RK003[/TD]
[TD][/TD]
[TD][/TD]
[TD]100[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]RK009[/TD]
[TD][/TD]
[TD][/TD]
[TD]28[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]RK002[/TD]
[TD][/TD]
[TD][/TD]
[TD]0[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]RK007[/TD]
[TD][/TD]
[TD][/TD]
[TD]155,000[/TD]
[/TR]
</tbody>[/TABLE]
What I'm trying to do: If column E is "0" then delete entire row but if column B has "RK003" then do not delete that row, even if column E has the value "0". My macro can only do the first half of what needs to be done but the second half (in orange font), I don't know how to do. I appreciate your help!
With ActiveSheet
.AutoFilterMode = False
With Range("E1", Range("E" & Rows.Count).End(xlUp))
.AutoFilter 1, "0"
On Error Resume Next
.Offset(1).SpecialCells(12).EntireRow.Delete
End With
.AutoFilterMode = False
End With
End Sub
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]column A[/TD]
[TD]column B[/TD]
[TD]column C[/TD]
[TD]column D[/TD]
[TD]Column E[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]RK001[/TD]
[TD][/TD]
[TD][/TD]
[TD]0[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]RK003[/TD]
[TD][/TD]
[TD][/TD]
[TD]0[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]RK005[/TD]
[TD][/TD]
[TD][/TD]
[TD]687[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]RK008[/TD]
[TD][/TD]
[TD][/TD]
[TD]0[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]RK003[/TD]
[TD][/TD]
[TD][/TD]
[TD]0[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]RK003[/TD]
[TD][/TD]
[TD][/TD]
[TD]100[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]RK009[/TD]
[TD][/TD]
[TD][/TD]
[TD]28[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]RK002[/TD]
[TD][/TD]
[TD][/TD]
[TD]0[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]RK007[/TD]
[TD][/TD]
[TD][/TD]
[TD]155,000[/TD]
[/TR]
</tbody>[/TABLE]