Is it possible to clear a large number of cells contents based on color alone? I don't think that simply filtering is going to work well on this because the dataset is large and 'wide'
3 Answers
If you don't need this done programatically, it can be faster to just use Find and Replace (Ctrl-H).
- Press
Ctrl-H
- Click
Options > >
- Click the top
Format...
button to search for for colored cells (use theFill
tab) - Leave the
Replace with
field blank to delete the contents of cells with the format you specified.
This will clear the content of any cell within the range A1:G8 filled with yellow (65535). Change the color for your color and the range for your range. This is kind of crude, sorry.
Sub Macro1()
Range("A1:G8").Select
For Each Cell In Selection
If Cell.Interior.Color = Excel.XlRgbColor.rgbYellow Then
Cell.Clear
End If
Next
End Sub
-
where can you find the decimal representation of colors at? Feb 13, 2012 at 20:26
-
You can use RGB, will probably be easier. I changed the macro. Also you can always record a macro and highlight a cell a color to find out its color code Feb 13, 2012 at 20:32
You can clear cells by background color using Excel's filter options.
For Excel 2013 & 2010
Open a worksheet where each column has a header row.
Enable column filtering with Data -> Sort & Filter -> Filter
Click the drop-down-arrow on a column, go to Filter by Color, and select a color you want to view. (Any non-colored cells will be hidden)
Select the remaining cells, right-click and select Clear Contents.
To unhide the remaining cells, disable column filtering with Data -> Sort & Filter -> Filter