View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
denise denise is offline
external usenet poster
 
Posts: 112
Default dual zero conditional row deletion

I want to set up a condition where a row is deleted ONLY if BOTH cells equal
zero. Currently the macro below delete the row when the first cell = zero.
Thus when there is something in the second cell and the first cell is zero
the row is deleted.

The code is below if someone could assist I would be greatful.

'
Sheets("Report").Select
Cells.Select
Selection.Copy
Sheets.Add
Cells.Select
ActiveSheet.Paste
Range("D11:H120").Select
Application.CutCopyMode = False
Selection.Copy
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Dim DeleteFlag As Boolean
DeleteFlag = True
While DeleteFlag = True
DeleteFlag = False
Range("A11:H120").Select
For Each rw In Selection.Rows
If rw.Cells(1, 4).Value = 0 And rw.Cells(1, 9) = 0 And
IsNumeric(rw.Cells(1, 1).Value) And Not IsEmpty(rw.Cells(1, 1)) Then
rw.Delete
DeleteFlag = True
'rw.Cells(1, 10).Value = "Zero"
End If
Next rw
Wend
Application.CutCopyMode = False
Range("D16").Select
ActiveWindow.Zoom = 85
Range("A3").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
ActiveSheet.Name = Right(Trim(Selection.Value), 5)
Application.CutCopyMode = False
Range("A3").Select
Sheets("Macro1").Select
Range("C2").Select
Selection.Delete Shift:=xlUp
Sheets("Report").Select
Range("A3").Select
ActiveCell.FormulaR1C1 = "=Macro1!R[-1]C[2]"
Range("A3").Select
Sheets("Data").Select
Range("D4:E88").Select
Selection.ClearContents
End Sub