Change certain background colors

S

Steve

Is there a way, via VBA or otherwise, to do sort of a "find and replace" on
background color? For example, if I want to change all of the cells with a
black background to having no background color....Thx.
 
B

Bob Phillips

Steve,

Here's a simple macro. Put the colour to change from in cellA1, the colour
to in A2, select your target cells and run the macro.

Sub ChangeCellColours()
Dim cell As Range
Dim mColFrom As Long
Dim mColTo As Long

mColFrom = Range("A1").Interior.ColorIndex
mColTo = Range("A2").Interior.ColorIndex

For Each cell In Selection
If cell.Interior.ColorIndex = mColFrom Then
cell.Interior.ColorIndex = mColTo
End If
Next cell

End Sub


--

HTH

RP
(remove nothere from the email address if mailing direct)
 
Top