Home

How to color a cell based directly on a cell value

%3CLINGO-SUB%20id%3D%22lingo-sub-850328%22%20slang%3D%22en-US%22%3EHow%20to%20color%20a%20cell%20based%20directly%20on%20a%20cell%20value%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-850328%22%20slang%3D%22en-US%22%3EOn%20mobile%20bc%20my%20internet%20isn't%20working%20today%3CBR%20%2F%3E%3CBR%20%2F%3EHow%20do%20I%20color%20a%20cell%20based%20not%20on%20its%20statistical%20relationship%20with%20other%20cells%2C%20but%20directly%20on%20its%20value%3F%20In%20particular%20I%20have%20a%20series%20of%20RGB%20values%20separated%20by%20channel%20and%20I'd%20like%20to%20include%20a%20sample%20of%20the%20color%20in%20question%20by%20the%20table.%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-850328%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-850355%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20color%20a%20cell%20based%20directly%20on%20a%20cell%20value%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-850355%22%20slang%3D%22en-US%22%3E%3CP%3EHello%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F403765%22%20target%3D%22_blank%22%3E%40rekkandevar%3C%2FA%3E%26nbsp%3B%2C%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EYou%20can%20use%20conditional%20formatting%20to%20set%20the%20color%20of%20a%20cell%20based%20on%20a%20value.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIf%2C%20however%2C%20you%20want%20to%20use%20the%20current%20value%20of%20the%20cell%20to%20set%20the%20fill%20color%20to%20the%20equivalent%20RGB%20%2C%20then%20that%20is%20not%20possible%20with%20conditional%20formatting%20or%20with%20any%20worksheet%20technique.%20That%20would%20require%20VBA.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ECan%20you%20post%20an%20example%20of%20the%20values%20your%20cells%20would%20have%3F%20RGB%20typically%20consists%20of%20three%20numeric%20values%2C%20not%20just%20one%20number%2C%20so%20I'd%20need%20to%20know%20how%20you%20store%20the%20RGB%20values%20in%20the%20cells.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-850358%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20color%20a%20cell%20based%20directly%20on%20a%20cell%20value%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-850358%22%20slang%3D%22en-US%22%3EIt's%20three%20columns%2C%20one%20per%20channel.%20I%20also%20created%20a%20custom%20format%2C%20(%23%230)%3B_(%23%230)%3B_(%23%230)%20%2C%20which%20hopefully%20would%20work%20as%20well.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-853528%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20color%20a%20cell%20based%20directly%20on%20a%20cell%20value%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-853528%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F403765%22%20target%3D%22_blank%22%3E%40rekkandevar%3C%2FA%3E%26nbsp%3BAs%20I%20said%2C%20there%20are%20no%20workbook%20functions%20or%20out%20of%20the%20box%20ways%20to%20use%20numbers%20in%20cells%20to%20fill%20a%20cell%20with%20RGB%20colors.%20This%20would%20require%20VBA.%20Are%20you%20open%20to%20that%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-853634%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20color%20a%20cell%20based%20directly%20on%20a%20cell%20value%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-853634%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F403765%22%20target%3D%22_blank%22%3E%40rekkandevar%3C%2FA%3E%26nbsp%3B%26nbsp%3BAttached%20is%20a%20file%20with%20a%20ChangeEvent%20macro%20working%20on%20Sheet%201.%20When%20you%20enter%20numbers%20into%20columns%20A%2C%20B%20and%20C%2C%20the%20cell%20in%20column%20D%20of%20the%20same%20row%20will%20be%20filled%20with%20the%20respective%20RGB%20value.%20You%20can%20copy%20and%20paste%20multiple%20values%20at%20the%20same%20time.%20Empty%20cells%20are%20treated%20as%20zero.%26nbsp%3B%20If%20the%20number%20combination%20results%20in%20invalid%20RGB%2C%20the%20cell%20fill%20will%20be%20removed%20and%20a%20warning%20displayed%20in%20the%20cell.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIs%20that%20something%20you%20can%20work%20with%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E
rekkandevar
New Contributor
On mobile bc my internet isn't working today

How do I color a cell based not on its statistical relationship with other cells, but directly on its value? In particular I have a series of RGB values separated by channel and I'd like to include a sample of the color in question by the table.
4 Replies

Hello @rekkandevar ,

 

You can use conditional formatting to set the color of a cell based on a value. 

 

If, however, you want to use the current value of the cell to set the fill color to the equivalent RGB , then that is not possible with conditional formatting or with any worksheet technique. That would require VBA.

 

Can you post an example of the values your cells would have? RGB typically consists of three numeric values, not just one number, so I'd need to know how you store the RGB values in the cells.

 

It's three columns, one per channel. I also created a custom format, (##0);_(##0);_(##0) , which hopefully would work as well.

@rekkandevar As I said, there are no workbook functions or out of the box ways to use numbers in cells to fill a cell with RGB colors. This would require VBA. Are you open to that?

@rekkandevar  Attached is a file with a ChangeEvent macro working on Sheet 1. When you enter numbers into columns A, B and C, the cell in column D of the same row will be filled with the respective RGB value. You can copy and paste multiple values at the same time. Empty cells are treated as zero.  If the number combination results in invalid RGB, the cell fill will be removed and a warning displayed in the cell.

 

Is that something you can work with?

Related Conversations
Tabs and Dark Mode
cjc2112 in Discussions on
46 Replies
flashing a white screen while open new tab
Deleted in Discussions on
14 Replies
How to Prevent Teams from Auto-Launch
chenrylee in Microsoft Teams on
29 Replies
Stable version of Edge insider browser
HotCakeX in Discussions on
35 Replies