want to change cell background using RGB data in a worksheet



I want to set up a worksheet with 1 column the colour name and have the
background of that cell be the colour. I also have a column for the Hex #
associated with that colour for the web. Also included are 3 more columns
each with the corrisponding RGB #'s (ie Column C = R, Column D = G, Column E
= B). Is there a formula that can take the data from each cell columns C,D,E
to create the fill colour for each corrisponding cell in column A?
(ie A3 = Dark Red, Columns CDE3 contain the RGB code for Dark Red, then A4 =
Crimson and CDE4 the RGB code for crimson).


Any particular reason why you want to split the RGB into three columns rather
than have it grouped into one column as the RGB(255, 255, 255) function
format which would allow for ready application without having to manipulate
cell values?


forgot to mention. only the first 8 colors have official names. all the rest
just have color index numbers.


Peter T

If you are asking for colours in cells to be updated by cell formulas, and
you don't want to customize the palette, which you can't for two reasons
(later), you are asking for two impossible things in one short question.
That's quite unusual !

First problem is a UDF cannot change the interface, which means it can't
apply colours. Problem regarding the palette relates in part to the first
problem, the UDF cannot customize palette colours, and even if it could, the
palette only contains 56 colours (which is limiting for getting a good
choice of colours for use in a web page).

However, on the basis that nothing is impossible, I have a little demo
workbook that overcomes both those impossibilities. The example allows for
three cells to be changed, which in turn are linked to formulas that make a
few thousand unique RGB colour values, and in turn will fill cells with
those unique colours. Contact me off-line if interested to see the demo.

When I started to read you question I thought it was going ask what cell
formulas would be required to convert web-hex RRGGBB into individual RGB
values, and perhaps then into a VB colour value. However I see you already
have the RGB's, though FWIW they can indeed be converted with cell formulas.

Peter T

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