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

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Activesheet.range("A1").interior.color for the RGB
Activesheet.range("A1").interior.colorindex for and indexed color.
 
Upvote 0
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.
 
Upvote 0
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?
 
Upvote 0

Forum statistics

Threads
1,214,621
Messages
6,120,563
Members
448,972
Latest member
Shantanu2024

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
Back
Top