# Solved: Delete highlighted cells in excel



## mean05stng (Mar 30, 2011)

I have a list in column A down to row 59325. Many cells are highlighted red. How can I delete all red cells? THANKS!


----------



## ckphilli (Apr 29, 2006)

Filter by color, select and delete.


----------



## mean05stng (Mar 30, 2011)

How do I filter by color?


----------



## bomb #21 (Jul 1, 2005)

Do you have Excel 2007?


----------



## mean05stng (Mar 30, 2011)

2003


----------



## bomb #21 (Jul 1, 2005)

Do you know macros? Can you run this with one of the red cells selected?

Sub test()
MsgBox ActiveCell.Interior.ColorIndex
End Sub


----------



## mean05stng (Mar 30, 2011)

It just gave me a pop up that said "2". Went to Tools/Macro/Visual Basic Editor - entered code and then Tools/Macro/Run.


----------



## bomb #21 (Jul 1, 2005)

2? 

Anyway: insert a new column A, then run this:

Sub test()
For Each Cell In Range("B1:B59325")
If Cell.Interior.ColorIndex = 2 Then
Cell.Offset(, -1) = "X"
End If
Next Cell
End Sub

Which is meant to give you an "X" in A wherever B is red.


----------



## mean05stng (Mar 30, 2011)

Didn't do anything. No error code. Just nothing. I have roughly 5000 rows to delete and REALLY don't want to do this manually!!!! Anything else I can do?


----------



## bomb #21 (Jul 1, 2005)

As hinted, it's meant to flag all the "red B" rows. But 2 *isn't* the "code" for red (for me, at any rate) so ... 

Any chance we can have a look at it (or part of it) somehow?

(at least "roughly 5000 rows" is a big improvement on 59325 )


----------



## mean05stng (Mar 30, 2011)

will you PM me? I'll shoot it over that way.


----------



## bomb #21 (Jul 1, 2005)

Addy sent by PM.


----------

