ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Excel 2003 - Color codes (https://www.excelbanter.com/excel-programming/423203-excel-2003-color-codes.html)

thomas

Excel 2003 - Color codes
 
Hello,

I was using the colorindex of the palette in my vba code (2003) but it's not
convenient because it gives different colors when the vba code is used on
excel workbooks with a different palette

I though i would get the same color whatever the palette by using RGB codes
instead but i have the same problem : For example, RGB (204, 255, 204) gives
different colors in different workbooks

How can i get always the same colors?

Thanks


Bob Phillips[_3_]

Excel 2003 - Color codes
 
The only way would be to configure the colours of every workbook as it was
opened. Excel will map any colour that you define to the closest match on
the standard color palette and use that colorindex.

--
__________________________________
HTH

Bob

"thomas" <nomail wrote in message
...
Hello,

I was using the colorindex of the palette in my vba code (2003) but it's
not
convenient because it gives different colors when the vba code is used on
excel workbooks with a different palette

I though i would get the same color whatever the palette by using RGB
codes
instead but i have the same problem : For example, RGB (204, 255, 204)
gives
different colors in different workbooks

How can i get always the same colors?

Thanks




Peter T

Excel 2003 - Color codes
 
The palette only contains 56 colours, in a default palette there are 10
duplicates. If you attempt to apply your own RGB Excel will match it to the
closest it can find in the palette.

Your particular RGB example does exist in a default palette, so if index 35
has not been customized you will get a perfect match.

If you want to be sure your colour is applied, but only customize a palette
colour if necessary you could do something like this

colVal = RGB(234, 255, 234) ' very pale green
With Range("a1").Interior
.Color = colVal
If .Color < colVal Then
' the RGB doesn't exist
ActiveWorkbook.Colors(25) = colVal
.ColorIndex = 25
End If
End With


Of course you'd need to be sure you are not messing with someones carefully
customized colour.

Regards,
Peter T


"thomas" <nomail wrote in message
...
Hello,

I was using the colorindex of the palette in my vba code (2003) but it's
not
convenient because it gives different colors when the vba code is used on
excel workbooks with a different palette

I though i would get the same color whatever the palette by using RGB
codes
instead but i have the same problem : For example, RGB (204, 255, 204)
gives
different colors in different workbooks

How can i get always the same colors?

Thanks




thomas

Re : Excel 2003 - Color codes
 
Many thanks

I now better understand



"Peter T" <peter_t@discussions a écrit dans le message de groupe de
discussion : ...
The palette only contains 56 colours, in a default palette there are 10
duplicates. If you attempt to apply your own RGB Excel will match it to the
closest it can find in the palette.

Your particular RGB example does exist in a default palette, so if index 35
has not been customized you will get a perfect match.

If you want to be sure your colour is applied, but only customize a palette
colour if necessary you could do something like this

colVal = RGB(234, 255, 234) ' very pale green
With Range("a1").Interior
.Color = colVal
If .Color < colVal Then
' the RGB doesn't exist
ActiveWorkbook.Colors(25) = colVal
.ColorIndex = 25
End If
End With


Of course you'd need to be sure you are not messing with someones carefully
customized colour.

Regards,
Peter T


"thomas" <nomail wrote in message
...
Hello,

I was using the colorindex of the palette in my vba code (2003) but it's
not
convenient because it gives different colors when the vba code is used on
excel workbooks with a different palette

I though i would get the same color whatever the palette by using RGB
codes
instead but i have the same problem : For example, RGB (204, 255, 204)
gives
different colors in different workbooks

How can i get always the same colors?

Thanks



thomas

Re : Excel 2003 - Color codes
 
so it's useless to use RGB codes. better keeping using colorindex ?


"thomas" <nomail a écrit dans le message de groupe de discussion :
...
Many thanks

I now better understand



"Peter T" <peter_t@discussions a écrit dans le message de groupe de
discussion :
...
The palette only contains 56 colours, in a default palette there are 10
duplicates. If you attempt to apply your own RGB Excel will match it to the
closest it can find in the palette.

Your particular RGB example does exist in a default palette, so if index 35
has not been customized you will get a perfect match.

If you want to be sure your colour is applied, but only customize a palette
colour if necessary you could do something like this

colVal = RGB(234, 255, 234) ' very pale green
With Range("a1").Interior
.Color = colVal
If .Color < colVal Then
' the RGB doesn't exist
ActiveWorkbook.Colors(25) = colVal
.ColorIndex = 25
End If
End With


Of course you'd need to be sure you are not messing with someones carefully
customized colour.

Regards,
Peter T


"thomas" <nomail wrote in message
...
Hello,

I was using the colorindex of the palette in my vba code (2003) but it's
not
convenient because it gives different colors when the vba code is used on
excel workbooks with a different palette

I though i would get the same color whatever the palette by using RGB
codes
instead but i have the same problem : For example, RGB (204, 255, 204)
gives
different colors in different workbooks

How can i get always the same colors?

Thanks



Peter T

Excel 2003 - Color codes
 
Not necessarily "useless to use RGB codes" at all, depends on the overall
scenario. Sometimes RGB values are exactly what you do want to use.

Regards,
Peter T

"thomas" <nomail wrote in message
...
so it's useless to use RGB codes. better keeping using colorindex ?


"thomas" <nomail a écrit dans le message de groupe de discussion :
...
Many thanks

I now better understand



"Peter T" <peter_t@discussions a écrit dans le message de groupe de
discussion :
...
The palette only contains 56 colours, in a default palette there are 10
duplicates. If you attempt to apply your own RGB Excel will match it to
the
closest it can find in the palette.

Your particular RGB example does exist in a default palette, so if index
35
has not been customized you will get a perfect match.

If you want to be sure your colour is applied, but only customize a
palette
colour if necessary you could do something like this

colVal = RGB(234, 255, 234) ' very pale green
With Range("a1").Interior
.Color = colVal
If .Color < colVal Then
' the RGB doesn't exist
ActiveWorkbook.Colors(25) = colVal
.ColorIndex = 25
End If
End With


Of course you'd need to be sure you are not messing with someones
carefully
customized colour.

Regards,
Peter T


"thomas" <nomail wrote in message
...
Hello,

I was using the colorindex of the palette in my vba code (2003) but it's
not
convenient because it gives different colors when the vba code is used on
excel workbooks with a different palette

I though i would get the same color whatever the palette by using RGB
codes
instead but i have the same problem : For example, RGB (204, 255, 204)
gives
different colors in different workbooks

How can i get always the same colors?

Thanks






All times are GMT +1. The time now is 12:20 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com