K
ksnapp
I need to delete any rows if they meet the following criteria
column D = 0
column C <> "TOTAL"
if column A = empty
then delete the row
but
if column A <> empty
then it needs to have its value moved one cell down and then delete th
row.
Here is what I tried and it leaves a bunch and has to be run severa
times
Sub Delete_if_zero_and_not_total()
Dim rw
rw = Cells(Rows.Count, 4).End(xlUp).Row
Range("D2", Cells(rw, 4)).Select
For Each CELL In Selection
Dim A As Single
Dim B As String
Dim C As String
A = CELL.Value
B = CELL.Offset(0, -1).Value
C = CELL.Offset(0, -3).Value
If A = Empty And B <> "TOTAL" And C = Empty Then
CELL.EntireRow.Delete
End If
If A = Empty And B <> "TOTAL" And C <> Empty then
CELL.Offset(1, -3).Value = C
CELL.EntireRow.Delete
End If
Next
End Su
column D = 0
column C <> "TOTAL"
if column A = empty
then delete the row
but
if column A <> empty
then it needs to have its value moved one cell down and then delete th
row.
Here is what I tried and it leaves a bunch and has to be run severa
times
Sub Delete_if_zero_and_not_total()
Dim rw
rw = Cells(Rows.Count, 4).End(xlUp).Row
Range("D2", Cells(rw, 4)).Select
For Each CELL In Selection
Dim A As Single
Dim B As String
Dim C As String
A = CELL.Value
B = CELL.Offset(0, -1).Value
C = CELL.Offset(0, -3).Value
If A = Empty And B <> "TOTAL" And C = Empty Then
CELL.EntireRow.Delete
End If
If A = Empty And B <> "TOTAL" And C <> Empty then
CELL.Offset(1, -3).Value = C
CELL.EntireRow.Delete
End If
Next
End Su