copy color from one sheet to another, not with CF

squirrellydw

Board Regular
Joined
Apr 2, 2015
Messages
90
Office Version
  1. 365
Platform
  1. Windows
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
 
What you describe should be easy to achieve through Conditional Formatting. Could you post your 2 sheets - the one with the list of names, and the one you want assessed - using the XL2BB - Excel Range to BBCode?
 
Upvote 0
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
I will give this a try later this week. I have about 15 sheets in the workbook that this needs to work on and needs to cover A2 to P40
 
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
I can't get this to work for some reason. Any chance you could upload a file with it already added?
 
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
OK I got it working but it's not doing what I want. I want to have a list of names on Sheet1 A3 to A23 that are in RED or whatever color I want. Then whenever that name is listed on Sheet2 it copies over the RED color. As a bonus it would be nice if it could copy over to other sheets that I make also, for example sheets3 to sheets 15
 
Upvote 0
Attached are two screenshots of what I would like. So anytime and anywhere the names from sheet1 show up on sheet 2 I would like them to copy the same color over automatically
 

Attachments

  • Sheet1.png
    Sheet1.png
    15.1 KB · Views: 2
  • Sheet2.png
    Sheet2.png
    40.7 KB · Views: 1
Upvote 0
If your desired format is the same for all cells on each sheet, I'd still be tempted to use Conditional Formatting, something like this:
Book1
AB
2
3Name1
4Name2
5Name3
6Name4
7Name5
8Name6
9Name7
10Name8
11Name9
12Name10
13Name11
14Name12
15Name13
16Name14
17Name15
18Name16
19Name17
20Name18
21Name19
22Name20
23
Names


Book1
ABCDEFGHIJKLMNOP
2
3Name1Name13
4
5Name2
6Name4NAME X
7Name14
8Name6
9NAME X
10Name8Name22Name7NAME X
11
12
13Name8NAME X
14Name12NAME XName10
15
16
17Name9
18
19Name11
20Name15NAME X
21
22
23Name25
24
25
26
27Name7
28
29
30
31
32
Sheet2
Cells with Conditional Formatting
CellConditionCell FormatStop If True
A2:P40Expression=COUNTIF(Names!$A$3:$A$22,A2)>0textNO
 
Upvote 0
Solution
If your desired format is the same for all cells on each sheet, I'd still be tempted to use Conditional Formatting, something like this:
Book1
AB
2
3Name1
4Name2
5Name3
6Name4
7Name5
8Name6
9Name7
10Name8
11Name9
12Name10
13Name11
14Name12
15Name13
16Name14
17Name15
18Name16
19Name17
20Name18
21Name19
22Name20
23
Names


Book1
ABCDEFGHIJKLMNOP
2
3Name1Name13
4
5Name2
6Name4NAME X
7Name14
8Name6
9NAME X
10Name8Name22Name7NAME X
11
12
13Name8NAME X
14Name12NAME XName10
15
16
17Name9
18
19Name11
20Name15NAME X
21
22
23Name25
24
25
26
27Name7
28
29
30
31
32
Sheet2
Cells with Conditional Formatting
CellConditionCell FormatStop If True
A2:P40Expression=COUNTIF(Names!$A$3:$A$22,A2)>0textNO
maybe I don't understand something but I didn't think I could do that easily with CF, I though I have to have a rule for each name?
 
Upvote 0

Forum statistics

Threads
1,226,835
Messages
6,193,241
Members
453,783
Latest member
Chandni

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