Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clear cell contents based on color?

Tags:

excel

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'

like image 227
wootscootinboogie Avatar asked Feb 13 '12 20:02

wootscootinboogie


2 Answers

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.
like image 175
stevepastelan Avatar answered Nov 01 '22 09:11

stevepastelan


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
like image 26
Raystafarian Avatar answered Nov 01 '22 10:11

Raystafarian