ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   changing an palette index value programmatically in Excel (https://www.excelbanter.com/excel-programming/294026-changing-palette-index-value-programmatically-excel.html)

brad

changing an palette index value programmatically in Excel
 
Hi all,

I'm stuck, is there any way to change the color a palette index
references from VBA.

for example I want to change the color that colorindex(3) references
from blue to green, that way all my cells that reference colorindex(3)
change from blue to green.

can I do this in VBA?

thanks a lot
b

Vasant Nanavati

changing an palette index value programmatically in Excel
 
This is a workbook-level setting. Did you try recording a macro?

Something like:

ActiveWorkbook.Colors(3) = RGB(0, 128, 0)

should work.

--

Vasant




"brad" wrote in message
om...
Hi all,

I'm stuck, is there any way to change the color a palette index
references from VBA.

for example I want to change the color that colorindex(3) references
from blue to green, that way all my cells that reference colorindex(3)
change from blue to green.

can I do this in VBA?

thanks a lot
b




Rick[_19_]

changing an palette index value programmatically in Excel
 
Hi,

Vasant is correct. This is what I insert in one of my
modules, for example, in some of my workbooks. You record
with the macro to get the precise RGB (red-green-blue)
numbers that you want.

Sub Auto_Open()

With ActiveWorkbook
.Colors(2) = RGB(233, 230, 254)
.Colors(11) = RGB(232, 254, 243)
.Colors(15) = RGB(255, 204, 255)
.Colors(16) = RGB(251, 223, 255)
.Colors(19) = RGB(255, 255, 195)
.Colors(34) = RGB(195, 255, 255)
.Colors(35) = RGB(195, 255, 195)
.Colors(47) = RGB(227, 252, 255)
.Colors(48) = RGB(228, 225, 224)
.Colors(49) = RGB(252, 255, 227)
.Colors(55) = RGB(255, 248, 227)
.Colors(56) = RGB(227, 255, 245)
End With

End Sub

Rick



All times are GMT +1. The time now is 03:32 PM.

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