How do I get multiple cells automatically change color/copy a different cell

Paul365

New Member
Joined
Oct 29, 2021
Messages
21
Office Version
  1. 2016
Platform
  1. Windows
  2. Mobile
Hello,

I am trying to have many cells on the same worksheet copy the cells color. Let's say I change cell 'A1' to green (or any color), I would like Cell 'A30' 'A50' 'A66' etc. to automatically change to the same color.

Can this be done? I know how to have the cell show the same text by using the formula =A1, howver I would like the boxes to show the same color too.

Any help would be great, I have looked into VBA and conditional formatting.
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
There is no event to detect (that triggers with) a change of color in a cell so try this workaround. Note that the other cells will color only when you move from cell A1 after changing it's color.
As per your example in a text workbook in ThisWorkBook's module paste this macro:
VBA Code:
Option Explicit
Private Sub Workbook_Open()
    Range("B1").Select                            '<- as range choose an unused cell but not A1
End Sub
and in the sheet's module paste this:
Code:
Option Explicit
Public LastRange As Range
Public LastCellColor As Integer
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Target.Cells.CountLarge > 1 Then Exit Sub
    If LastCellColor = 0 Then GoTo setvar
    If LastRange.Interior.ColorIndex <> LastCellColor Then
        If Not Intersect(LastRange, Range("A1")) Is Nothing Then
            Union(Range("A30"), Range("A50"), Range("A66")).Interior.ColorIndex = LastRange.Interior.ColorIndex
        End If
    End If
setvar:
    Set LastRange = Target
    LastCellColor = Target.Interior.ColorIndex
End Sub
If the test goes well, try integrating everything into your project.
 
Upvote 0

Forum statistics

Threads
1,224,592
Messages
6,179,789
Members
452,942
Latest member
VijayNewtoExcel

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top