If I were to manually select a particular cell back colour, could I put code behind another selected cell and say whatever cell D1 back colour is being used then make this cell back colour the same? Hope thats not confusing. Thanks
Right click on worksheet tab.
Click view code.
Add the following to the Worksheet SelectionChange event:
If Target.Column = 2 Then
Target.Cells(1, 3).Interior.ColorIndex = Target.Cells.Interior.ColorIndex
End If
Now when you click on a cell in Column B the background color of the cell in Column D changes to match the cell in Column B.
Thanks Skip/Ben. I have looked at conditional formatting, but I am trying to find a way to reference what the fillcolor is in one cell and propogate that color to other cells within workpages that get referenced to. In other words not by any value, just cell references xxx = fillcolor of YYY.
Ben, I tried putting your code in, it worked once, I think after opening and closing the code window, but after changing the cell color of the master cell to another color, entering a change in the other cell did not change its color to that of the master cell. I tried putting the code in the change event, but still nothing. I must say I know nothing much about Excel, so appreciate the help. Thanks.
Thanks Ben, I went back to it and realised it works if you click the cell. I will wake up soon. Can one make reference to drill down the requested code to other sheets/pages? Thanks
What you could do is create a Name for all of the cells involved. You would select the cells, go to Insert, Name, Define, code below assumes name is CellsToMatchD1. For non-contiguous selecting you hold down Ctrl before clicking on the cell. The disadvantage of doing it this way is you will need to make sure it refers to the right cells anytime you add or delete columns/rows.
Following code should replace prior code (it now only works after selecting Cell D1):
If Target.Column = 1 And Target.Row = 4 Then
ActiveWorkbook.Names("CellsToMatchD1").RefersToRange.Cells.Interior.ColorIndex = Target.Cells.Interior.ColorIndex
End If
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.