macro for copying background color

G

Guest

I need a macro that does the following:

If a cell contains the text "N/A" I need the background color of the cell
adjacent and to the left of it, copied and pasted into the cell with "N/A"

So, B1 has "N/A". I need the background color from A1 copied into cell B1,
leaving the text "N/A" intact.

If B2 has "N/A" I need the background or fill color from cell A1 copied into
B2.


In all cases the fill color is just a solid color. I need no other
formatting or content copied, just the fill color.
 
G

Guest

Paste this into a standard Module:

Sub tester()
Set Rng = Selection
For Each c In Rng
If c = "N/A" Then
c.Interior.ColorIndex = Range("A1").Interior.ColorIndex
End If
Next c
End Sub

Then before runing Macro - Highlite your cells (Say B1:B10) then run Tester.
 

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

Top