ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   RGB for cell interior (https://www.excelbanter.com/excel-programming/366739-rgb-cell-interior.html)

Zone

RGB for cell interior
 
I want to apply an RGB color to a cell interior using VBA. TIA, James


Don Guillett

RGB for cell interior
 
Sub rgbcolorinterior()
Range("j6").Interior.Color = RGB(228, 234, 244)
End Sub

--
Don Guillett
SalesAid Software

"Zone" wrote in message
oups.com...
I want to apply an RGB color to a cell interior using VBA. TIA, James




Abe[_4_]

RGB for cell interior
 
James,

The excel color palate only allows for 50ish (55?) colors, so if you
want to set a specific RGB color, you will first need to edit the
palate of your excel file.

ActiveWorkbook.Colors(colorindex) = RGB(red, green, blue)

where red, green and blue are integers between 0 and 255 and the color
index is also an integer.

Then, you can apply that color to cells via (example sets the interior
color of cell A1 to your defined color):

range("A1").Interior.Color = ActiveWorkbook.Colors(colorindex)

HTH,

Abe

Zone wrote:
I want to apply an RGB color to a cell interior using VBA. TIA, James



Abe[_4_]

RGB for cell interior
 
Don, correct me if I am wrong, but doesn't that just take the closest
approximation in excel's active palate to the RGB color?

-Abe

Don Guillett wrote:
Sub rgbcolorinterior()
Range("j6").Interior.Color = RGB(228, 234, 244)
End Sub

--
Don Guillett
SalesAid Software

"Zone" wrote in message
oups.com...
I want to apply an RGB color to a cell interior using VBA. TIA, James



JE McGimpsey

RGB for cell interior
 
Since XL can only display the 56 colors in the color palette, using

Cells(1, 1).Interior.Color = RGB(63, 127, 255)

will choose the "closest" color in the palette.

You can change one of the colors in the palette to include your color:

ActiveWorkbook.Colors(37) = RGB(63, 127, 255)

You can then assign the color using the ColorIndex property:

Cells(1, 1).Interior.ColorIndex = 37



In article .com,
"Zone" wrote:

I want to apply an RGB color to a cell interior using VBA. TIA, James


Bob Phillips

RGB for cell interior
 
Yes it does, and you cannot do what you want to do without changing one of
the standard colours to the colour combination that you want.

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Abe" wrote in message
oups.com...
Don, correct me if I am wrong, but doesn't that just take the closest
approximation in excel's active palate to the RGB color?

-Abe

Don Guillett wrote:
Sub rgbcolorinterior()
Range("j6").Interior.Color = RGB(228, 234, 244)
End Sub

--
Don Guillett
SalesAid Software

"Zone" wrote in message
oups.com...
I want to apply an RGB color to a cell interior using VBA. TIA, James





Zone

RGB for cell interior
 
Many thanks, everyone. Seems like more Excel wierdness that RGB colors
can be applied directly to shapes but not to cells. I suppose this is
intended to conserve memory.
Tally-ho!
James

JE McGimpsey wrote:
Since XL can only display the 56 colors in the color palette, using

Cells(1, 1).Interior.Color = RGB(63, 127, 255)

will choose the "closest" color in the palette.

You can change one of the colors in the palette to include your color:

ActiveWorkbook.Colors(37) = RGB(63, 127, 255)

You can then assign the color using the ColorIndex property:

Cells(1, 1).Interior.ColorIndex = 37



In article .com,
"Zone" wrote:

I want to apply an RGB color to a cell interior using VBA. TIA, James




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

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