J
Josh Sale
I have what I think should be a very simple problem but I can't quite puzzle
it out. Basically I want to copy the background color from one arbitrary
cell to another arbitrary cell. I want this process to work even if the
user has formatted the source cell using a color from a custom color
palette.
I currently have code that looks more or less like this:
If SourceRange.ColorIndex <> xlNone Then
TargetRange.Interior.ColorIndex = SourceRange.ColorIndex
TargetRange.Interior.Color = SourceRange.Color
End If
Mostly this seems to work OK. However sometimes it fails (that is the wrong
background color appears). I think in these cases it because the source
range has a custom background color.
Source and Target are always in different workbooks so I have a line like
this in my code:
TargetRange.Parent.Parent.Colors = SourceRange.Parent.Parent.Colors
to try to copy the custom color palette from the source workbook into the
target workbook.
I have to admit I'm fuzzy on difference between the Color and ColorIndex
properties. I gather the former is an rgb value and the latter is an index
into the palette. Do I need to copy both to get my colors? One? Which
one?
TIA
josh
it out. Basically I want to copy the background color from one arbitrary
cell to another arbitrary cell. I want this process to work even if the
user has formatted the source cell using a color from a custom color
palette.
I currently have code that looks more or less like this:
If SourceRange.ColorIndex <> xlNone Then
TargetRange.Interior.ColorIndex = SourceRange.ColorIndex
TargetRange.Interior.Color = SourceRange.Color
End If
Mostly this seems to work OK. However sometimes it fails (that is the wrong
background color appears). I think in these cases it because the source
range has a custom background color.
Source and Target are always in different workbooks so I have a line like
this in my code:
TargetRange.Parent.Parent.Colors = SourceRange.Parent.Parent.Colors
to try to copy the custom color palette from the source workbook into the
target workbook.
I have to admit I'm fuzzy on difference between the Color and ColorIndex
properties. I gather the former is an rgb value and the latter is an index
into the palette. Do I need to copy both to get my colors? One? Which
one?
TIA
josh