PDA

View Full Version : Solved: Delete if matching colour



walkerke2
07-11-2008, 12:22 AM
Hi All,

I'm a newbie so just let me know if I can manipulate it a little to the needed.

The data is coloured green when the jobs have been processed but this code will only delete a portion of the completed green coloured jobs.

I want' it to delete all green rows.

Any help much appreciated.
Sub DeleteGreen()
Dim R As Range, c As Range
Set R = ActiveSheet.Range("A:A")
For Each c In R
If c.Interior.Color = vbGreen Then
c.EntireRow.Delete
End If
Next c
End Sub

Bob Phillips
07-11-2008, 12:38 AM
Sub DeleteGreen()
Dim LastRow As Long
Dim i As Long

With ActiveSheet

LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
For i = LastRow To 1 Step -1

If .Cells(i, "A").Interior.Color = vbGreen Then

.Rows(i).Delete
End If
Next i
End With
End Sub

walkerke2
07-11-2008, 01:15 AM
Thanks xld magic works a treat.