View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
JE McGimpsey JE McGimpsey is offline
external usenet poster
 
Posts: 4,624
Default 2 x Case // Error why ?

One way:

Format a cell with RGB, then read the colorindex:

Dim nMyColorIndex As Long
Dim nOldColorIndex As Long
With Range("IV1").Interior
nOldColorIndex = .ColorIndex
.Color = RGB(255, 128, 128)
nMyColorIndex = .ColorIndex
.ColorIndex = nOldColorIndex
End With



In article ,
"Philipp Oberleitner" wrote:

How can i see what colorindex to use which is nearest to my rgb RGB(255,
128, 128) ß

Thanks alot+


"JE McGimpsey" wrote in message
...
Couple of problems here.

First, Cells/Range doesn't have a Color property. For background color,
you need to use

Select Case Blatt.Cells(i, "K").Interior.Color

Second, XL can only display 56 colors at a time, so unless the RGB value
is one of the 56 colors in the color palette, it won't match. When you
assign an RGB value, XL tries to find the closest match. For instance,
when I enter this in the immediate window with the default palette:

Cells(1,"K").interior.Color = RGB(128,255,196)
?RGB(128,255,196)
12910464
?cells(1,"K").interior.color
13434828
?cells(1,"K").interior.color=RGB(128,255,196)
False