PDA

View Full Version : Solved: Macro: Delete Highlighted Rows



Weezer
09-27-2010, 04:59 PM
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

Simon Lloyd
09-27-2010, 11:19 PM
This will delete ALL columns that have a coloured cell in them:
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

Weezer
09-28-2010, 08:55 AM
Simon Lloyd aka Simon The Legend. Your code works perfectly, thank you very much sir!

Simon Lloyd
09-28-2010, 11:50 AM
Glad i could help, please mark the thread solved by going to thread tools and then Mark Solved :)