changing the color of a cell

Z

zhj23

Hello! Gurus

Is there a way to change the color of a cell to some specific RGB
combinations in addition to the standard color palette provided?

It would be good if we can add this special color to the palette for future
use.

Thanks.

zhj23
 
G

Gord Dibben

Tools>Options>Color>Modify will allow you change a color to any rgb value you'd
like.

Or run a macro with your parameters.

Sub foo()
ActiveCell.Interior.Color = RGB(170, 112, 230)
End Sub


Gord Dibben MS Excel MVP
 
C

Conan Kelly

Gord,

Please correct me if i'm wrong, but you can not set a cell color to a color
that is not in XL's ColorIndex Color Pallette (pardon the
terminology....please correct).

I think I tried this once......tried to color a cell to an rgb value that
did not have an index # and XL adjusted it to the nearest color that was
assigned an index # (was using XL 2002 when I tried this, now using
2003...have not tried it).

Is that correct?

Thanks,

Conan
 
Z

zhj23

Gord:

Thanks for the reply.

I prefer not to "modify", but "add" on to the color palette, so that I will
not lose the standard colors.


zhj23
 
F

FSt1

hi,
you are corrected. xl does limit the total number of colors available to 56
but as Gord pointed out(tool>options>color>modify button>costom OR standard
tab) you can modify any of the standard 56 xl colors. and with 256 increments
of the RGB, you have 256 x 256 x256 or 16,777,216 colors combinations
available to you. Of course you can only display 56 of those colors at one
time due to xl limitations but you can get real colorful if you want.
sorry.
FSt1
 
T

T. Valko

As far as I know, you can't add, you can only replace. If you add a new
color it replaces one of the already existing colors.
 
C

Conan Kelly

FSt1, Gord, Chip Pearson, or anyone else who knows,

While we are on the subject of color, I took the following sub routine from
Chip's website (http://www.cpearson.com/excel/colors.htm):

Sub GetRGB(RGB As Long, ByRef Red As Integer, _
ByRef Green As Integer, ByRef Blue As Integer)
Red = RGB And 255
Green = RGB \ 256 And 255
Blue = RGB \ 256 ^ 2 And 255
End Sub


Now my question is, in the line that reads:

Red = RGB And 255

mathematically, exactly what is going on here? I thought "And" was a
logical operator. How can "RGB And 255" return anything other than
TRUE/FALSE (or 1/0)?

Thanks for the help,

Conan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top