Cells Color Properties

shannondbaker

Board Regular
Joined
Sep 25, 2003
Messages
121
Good Afternoon Board,

I want visual basic to assign an exact color to a cell but I don't know how to select more than the default colors allowed. I ultimately need to give it the command for RGB (red, green, blue) and possibly HSL (hue, saturation, luminance). Below, you will find code for a cell and a textbox. I want to be able to have as much control as the textbox code for the cell. I'm sure this is a minor overlook on my part, but your help would be appreciated.

Thanks in advanced,

Shannon

SAMPLE CODE (Textbox):

ActiveSheet.Shapes("Text Box 16").Select
Selection.ShapeRange.Fill.ForeColor.RGB = RGB(51, 153, 255)

SAMPLE CODE(Cell):

With Selection.Interior
.ColorIndex = 30
End With
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop

Cbrine

Well-known Member
Joined
Dec 2, 2003
Messages
3,196
Activesheet.range("A1").interior.color for the RGB
Activesheet.range("A1").interior.colorindex for and indexed color.
 

Juan Pablo González

MrExcel MVP
Joined
Feb 8, 2002
Messages
11,959
For cells you can only have 56 colors... you can try to use the RGB color to use a different one, one that is not defined in the 56 color palette, but then Excel will try to use the closest one to it.
 

Wayne L.

Board Regular
Joined
Jul 23, 2002
Messages
111
Juan, is it possible for VBA to modify the default palette? If so, would the modified palette be attached to the workbook, or the application?
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,151,883
Messages
5,766,911
Members
425,385
Latest member
djkevnic

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top