copy color from one sheet to another, not with CF

squirrellydw

Board Regular
Joined
Apr 2, 2015
Messages
66
Is there away I can copy color from one sheet to another without using conditional formatting because I don't think it will work. What I'm trying to do is have a list of names on one sheet and whenever that name is listed anywhere on another sheet have it show up as red. thanks
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Try. This code will copy value and color only. This will not copy CF. Copies from A2:A10 To G2:G10.
VBA Code:
Sub copyColorOfCF()
Dim Rng As Range, DestRngb As Range, cel As Range
Dim Ro&
Set Rng = Range("A2:A10")
Set DestRng = Range("G2")
For Each cel In Rng
With DestRng.Offset(Ro, 0)
.Value = cel.Value
.Interior.Color = cel.DisplayFormat.Interior.Color
End With
Ro = Ro + 1

Next cel

End Sub
 
Upvote 0
I have included Sheet names.
This code will copy value and color only. This will not copy CF. Copies from Sheet2 A2:A10 To Sheet3 G2:G10.
VBA Code:
Sub copyColorOfCF()
Dim Rng As Range, DestRng As Range, cel As Range
Dim Ro&
Set Rng = Sheets("Sheet2").Range("A2:A10")
Set DestRng = Sheets("Sheet3").Range("G2")
For Each cel In Rng
With DestRng.Offset(Ro, 0)
.Value = cel.Value
.Interior.Color = cel.DisplayFormat.Interior.Color
End With
Ro = Ro + 1

Next cel

End Sub
 
Upvote 0

Forum statistics

Threads
1,226,115
Messages
6,189,053
Members
453,522
Latest member
Seeker2025

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