I have a spreadsheet that someone has changed the row color on rows we want to delete.
Is there a way to delete any row that is say...yellow for example?
I do not know excel vba at all FYI.
As this thread is old maybe your problem is solved, but if not then you must, I believe, use code.
The code below should be copied into a module and works as follows
Select a cell that contains the colour of the rows you wish to delete
Run the macro
Code:
Sub deletebycolour()
'Brian Warnock 20/09/06
Dim lngCounter As Long
Dim lngLastRow As Long
ci = ActiveWindow.RangeSelection.Interior.ColorIndex
With ActiveSheet.UsedRange
lngLastRow = .Cells(1, 1).Row + .Rows.Count - 1
End With
lngCounter = 1
Application.ScreenUpdating = False
Do While lngCounter <= lngLastRow
Set r = Range("a1")
If r.Cells(lngCounter, 1).Interior.ColorIndex = ci Then
Rows(lngCounter).Delete
lngCounter = lngCounter
lngLastRow = lngLastRow - 1
Else
lngCounter = lngCounter + 1
End If
Loop
Application.ScreenUpdating = True
End Sub
Just in case, to copy the code into a module Alt+F11 opens up the VBA editor, you should see your spreadsheet listed on the left in the project pane, if not Ctrl+r will open that then Insert module from the menu bar and drop down will give you a module to cut and paste the code into