Consulting

Results 1 to 3 of 3

Thread: Solved: Delete if matching colour

  1. #1
    VBAX Regular
    Joined
    Apr 2008
    Location
    Edinburgh
    Posts
    21
    Location

    Smile Solved: Delete if matching colour

    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.
    [vba]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[/vba]

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [VBA]

    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
    [/VBA]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Regular
    Joined
    Apr 2008
    Location
    Edinburgh
    Posts
    21
    Location
    Thanks xld magic works a treat.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •