Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 269
Default RGB for cell interior

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default 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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default 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


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default 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


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default 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



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default 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




  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 269
Default 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


Reply
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
Cell interior color JohnB Excel Discussion (Misc queries) 4 October 12th 06 06:07 PM
RGB value of cell interior Brotha lee Excel Programming 8 May 20th 05 12:47 AM
Conditional Format with VBA - Interior Colour of cell based on value from in-cell dropdown Steve[_52_] Excel Programming 5 June 15th 04 11:45 AM
Interior Cell color Pellechi Excel Programming 1 September 23rd 03 03:39 PM


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

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

About Us

"It's about Microsoft Excel"