Change certain background colors

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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

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

Back
Top