LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 177
Default ColorIndex vs Color?

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



 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
themecolor, colorindex, color picker Sindi Excel Programming 0 October 22nd 07 07:55 PM
Color vs Colorindex for series border HC Hamaker Charts and Charting in Excel 1 May 16th 07 02:37 AM
tab.colorindex linked to cell color Mike Excel Worksheet Functions 2 April 12th 07 12:44 AM
ColorIndex returns incorrect color [email protected] Excel Programming 1 October 10th 06 07:06 PM
Name of color for a particular colorindex number Hari[_3_] Excel Programming 2 June 8th 04 07:13 PM


All times are GMT +1. The time now is 07:10 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"