Consulting

Results 1 to 4 of 4

Thread: Solved: Macro: Delete Highlighted Rows

  1. #1
    VBAX Regular
    Joined
    Sep 2010
    Posts
    13
    Location

    Solved: Macro: Delete Highlighted Rows

    Hey all!

    How do I delete columns that have a color fill in them/ if the entire column is highlighted. Currently I am doing it by specifying the column names, but I was wondering if this could be done dynamically.

    Thanks

  2. #2
    Moderator VBAX Guru Simon Lloyd's Avatar
    Joined
    Sep 2005
    Location
    UK
    Posts
    3,003
    Location
    This will delete ALL columns that have a coloured cell in them:
    [VBA]Sub cols()
    Dim MyCell As Range
    For Each MyCell In ActiveSheet.UsedRange
    If MyCell.Interior.ColorIndex <> xlNone Then
    MyCell.EntireColumn.Delete
    End If
    Next
    End Sub[/VBA]
    Regards,
    Simon
    Please read this before cross posting!
    In the unlikely event you didn't get your answer here try Microsoft Office Discussion @ The Code Cage
    If I have seen further it is by standing on the shoulders of giants.
    Isaac Newton, Letter to Robert Hooke, February 5, 1675 English mathematician & physicist (1642 - 1727)

  3. #3
    VBAX Regular
    Joined
    Sep 2010
    Posts
    13
    Location
    Simon Lloyd aka Simon The Legend. Your code works perfectly, thank you very much sir!

  4. #4
    Moderator VBAX Guru Simon Lloyd's Avatar
    Joined
    Sep 2005
    Location
    UK
    Posts
    3,003
    Location
    Glad i could help, please mark the thread solved by going to thread tools and then Mark Solved
    Regards,
    Simon
    Please read this before cross posting!
    In the unlikely event you didn't get your answer here try Microsoft Office Discussion @ The Code Cage
    If I have seen further it is by standing on the shoulders of giants.
    Isaac Newton, Letter to Robert Hooke, February 5, 1675 English mathematician & physicist (1642 - 1727)

Posting Permissions

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