5

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 3

7

If you don't need this done programatically, it can be faster to just use Find and Replace (Ctrl-H).

  1. Press Ctrl-H
  2. Click Options > >
  3. Click the top Format... button to search for for colored cells (use the Fill tab)
  4. Leave the Replace with field blank to delete the contents of cells with the format you specified.
0
4

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
2
  • 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
0

You can clear cells by background color using Excel's filter options.


For Excel 2013 & 2010

  1. Open a worksheet where each column has a header row.

    Worksheet with header row

  2. Enable column filtering with Data -> Sort & Filter -> Filter

    Clicking the filter command

  3. 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)

    Filtering a column

  4. Select the remaining cells, right-click and select Clear Contents.

    Selecting clear contents

  5. To unhide the remaining cells, disable column filtering with Data -> Sort & Filter -> Filter

    Final results without colored cells

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.