how to delete excel cells that are color-filled?

M

Mikrolet

I have a spreadsheet where some cells are color-filled. I am trying to
delete the cells that are color-filled with green and leave those that
are not color-filled. The problem is, the color-filled cells are
scattered all over the 60k-row spreadsheet and manually deleting them
is a pain.

Does anybody have any idea how to do this quickly? Any macros would be
appreciated.

Thanks.
 
G

Guest

First of all, I'm not sure what you meant by "delete cells"
Two possibilities
1) You got plenty of cells on your spreadsheet. In many columns. You want to make those colored cells empty
2) You got a single-column spreadsheet. You want to scan through the column, and delete the rows which are colored

For (1), you can try this macro. You do not need select anything. Just run the macro and it scans through all cells on the spreadsheet and make all those colored cells empty
*************************************
Sub clear_cells(
Dim cell As Objec
With ActiveSheet.UsedRang
For Each cell In .Cell
If cell.Interior.ColorIndex <> -4142 The
cell.Value = "
End I
Nex
End Wit
End Su
**************************************

For (2), try the macro below. Select the column of cells you want to scan and then run the macro
***************************************
Sub delete_rows(
Dim tmp As Singl
With Selectio
If Selection.Columns.Count > 1 The
MsgBox ("This macro works only with a single-column selection. Please try again."
Els
For tmp = .Cells.Count To 1 Step -
If .Cells(tmp).Interior.ColorIndex <> -4142 The
.Cells(tmp).EntireRow.Delet
End I
Nex
End I
End Wit
End Su
****************************************

Regards
Edwin Ta
(e-mail address removed)
http://www.vonixx.co


----- Mikrolet wrote: ----

I have a spreadsheet where some cells are color-filled. I am trying t
delete the cells that are color-filled with green and leave those tha
are not color-filled. The problem is, the color-filled cells ar
scattered all over the 60k-row spreadsheet and manually deleting the
is a pain

Does anybody have any idea how to do this quickly? Any macros would b
appreciated

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top