Excel 2016: Adding Gradient Formats for Cell Background and Font? - excel

I'm using Microsoft Excel 2016 to construct a forecast model with a range of outputs. I have used Excel's built-in Conditional Formatting setting (Graded Color Scale, to be precise) to make the outputs visually informative, setting a green gradient scale to distinguish between low-valued outputs and high-valued outputs.
The minimum-valued cell background is set to 'Green, Accent 6, Lighter 80%' and the maximum-valued cell background is set to 'Green, Accent 6'. This has worked well. The cell values near the maximum, however, can sometimes be difficult to read, since they are 'Black, Text 1' (not a great contrast with the darker Green).
I am hoping to add the same type of conditional formatting to the cell texts in the range of outputs to generate a color contrast: for example, in the lighter end of the gradient, the cell texts will be 'Black, Text', and in the darker end of the gradient, the cells texts will be 'White, Background.' Visually, that would solve my contrast issue.
Unfortunately, after reading through this forum and searching for conditional formatting guides on Google, I haven't found a solution on how to apply the two types of formatting (background and font) to the same range of cells. I am not practiced in VBA, so I am hoping for any pointer that involves Excel's native functionality, if that's possible.
To boil all this down into a one-liner: "How do I add gradient conditional formatting to both font and background to a range of cells?"
Thank you for the help!

I have done this in the past by creating a number of rules that give the appearance of a gradient on both. To do this however you would create as many rules you need to get the resolution you want. For example:
Suppose you want to assign font and background fill for each value in increments of 10% from 0 to 100%.
For this you need to get 10 font colors in rgb format that gradually shift in the gradient that you want here is a site that can help:
http://www.colorizer.org/
Then do the same with for you background colors.
Now pair a font and background color with the range that you want that rule to apply to and write the excel rule.
While this method is a pain to set up it avoids vba at all costs and if you use the sheet as a template for other sheets you won't have to mess with it much.

Creating your own sets of custom rules as per #rahicks answer in the most comprehensive way of doing this. If you have a fairly stable range of values, then a quick and dirty solution is to use Custom Number Formats.
On top of your current conditional formatting, apply a Custom Number Format using a condition. This example sets the colour to white if the value is greater than 50, and then uses the existing colour otherwise.
[White][>50]General;General
You'll need to replace 50 with the mid-point of your data range and you'll also need to replace both instances of General with whatever number format you currently have on the range.

Related

Is it possible to create a drop down in Excel with no text just color options to fill a cell?

As the title says, I would like to create a dropdown with no text only color options to fill the cell. I'd like to give only a few specific options to the user, for convenience and simplicity.
It would also facilitate my VBA coding because I'm using cells().Interior.ColorIndex to identify the color and do certain tasks depending on the color chosen. So, I suppose I'm restricted by the 56 colors in the index color pallet of Excel.
Is this possible?
Well, I didn't accomplish what I wanted 100% but with the help of Stackoverflow developers I got to a pretty cool result which works perfectly for what I wanted and it could probably be useful for someone else.
So what I did was a drop down menu with the colour names and a Conditiontal Formatting which converts the text and fill of the cell to the specific colour. I downsized the font size to 1, so I can use them as small rectangles.

Alternating Color of Rows with Merged Rows in Leading Column - Excel 2016

I'm trying to create an Excel sheet that will be tracking some of our autonomous processes and their access privileges at my company and I've run into an issue with Excel..
I'm trying to alternate row colors, which in and of itself isn't an issue, however the fact that I've got merged rows are giving me issues.
As of right now I've got 5 columns with headers in A through E. Column F is being used for conditional formatting to color the rows. In column F this formula is present:
=MOD(IF(ROW()=2,0,IF(A2=A1,F1, F1+1)), 2)
This works great if I want to repeat the leading Column item over and over, however I'd like to reduce the visual clutter and increase clarity, so I've merged some of the rows in the Column A because multiple rows in B:E correspond to it.
I've merged A2:A4 right now and the formula picks up the A2 and A4 as blank, but A3 (the text in the merged cell is centered) is recognized as different that A2 and A4 because the text resides there. I'll upload an image to give a better idea of what I'm talking about as well.
If anyone can give me a tip on how to alternate row colors with merged cells/rows that'd be great, I've done a lot of googling and searching on stackoverflow, but for the most part I've only found things that pertain to unmerged rows/cells.
Image Example: https://imgur.com/a/UDbRVWA
=IF() Condition that worked for me:
=MOD(IF(ROW()=2,0,IF((A2=0),IF((OR(A1<>0,A2=A1)),F1, F1+1),F1+1)), 2)
There is an answer below with a picture I posted, however, for most situations I would recommend the method suggested by #BruceWayne. It's far more sensible than working with merged cells!
I ended up finding a solution with just some clever working with the Conditional IF() statements. I think the key was taking into account that the Merged Cells that weren't the top (i.e. If I merged A2:A4, A2 is top, A3, A4 bottom) were equal to 0 while the top was set to the value of the text within the merged cell. Using the formula below I was able to achieve the result I was after:
=MOD(IF(ROW()=2,0,IF((A2=0),IF((OR(A1<>0,A2=A1)),F1, F1+1),F1+1)), 2)
And here is a linked screenshot: https://imgur.com/a/gNaC62c
I then just added conditional formatting for every row but row 1: =$F2=1. I'll be hiding column F to make it seem less obtrusive.
For future reference, I would agree with what #BruceWayne mentioned in that a simpler formatting that gets the job done would be preferable. There are many other ways to format this in a way that makes much more sense, but I felt like I was close when I was tinkering with it, so I stuck with it another 15 minutes or so and was able to pull out a usable formatting condition.
Might I make a suggestion? If the merging rows is to increase clarity with repeated entries, perhaps we can use another Conditional Formatting rule to make it more legible.
Say you have data that looks like this:
But, we don't want to see <Process #> duplicates in the A column. We could merge these cells and center it along the rows. But again, merging cells is generally frowned upon I've found. (It makes it tricky to format, conditional format, copy/paste, do any VLOOKUP()/Index/Match, etc.)
First, let's get the rows alternating colors. I'm using fill of RGB(183, 255, 253):
New Rule 1 -
Formula: =MOD(ROW(),2)
Applies To Range: $A$2:$E$9
Format: Fill with color RGB 183, 255, 253 (...or whatever you want, just note the RGB for later)
Now, we get this:
Okay, making progress. Now, let's work on hiding the duplicate values in column A.
So, let's apply some more Conditional Formats. We'll need two for column A, one to set the font to White, one to set the Font to that blue fill color.
New Rule 2 -
Formula: =AND($A3=$A2,MOD(ROW(),2)=1)
Applies To: =$A$3:$A$100
Format: Font --> Color --> RGB(183, 255, 253)
New Rule 3 -
Formula: =AND($A3=$A2,MOD(ROW(),2)=0)
Applies To: =$A$3:$A$100
Format: Font --> Color --> White
Now we have:
IMO, we can do one more thing to clarify the breaks in Processes:
New Rule 4 -
Formula: =$A2<>$A1
Applies To: =$A$2:$E$100
Format: Border --> Top Border
Now, we have a nice new CF table.

Colour scale based on how far value is from other cell value

I have a column of targets (C2:C30) and a column of projections (D2:D30).
I've been able to conditionally format the projections to highlight values either above or below target, but I want to expand this into a colour scale to be able to identify more quickly how far from the target my projection is.
For example, if D:D is above 90% of C:C, a green colouring would suffice. 80-90% would be amber, below 80% would be red. In an ideal world, a fully fledged colour scale would be great but at this moment in time I'll be happy with anything more sophisticated than my current above/below setup.
I believe I could use a series of stacked conditional formats but thought there might be a more efficient way of doing this?
You can create your own scale,
Create first rule using something like:
=C2*1.9<D2
Apply this in Cell D2, then apply to D2:D30,
Then create second rule:
=C2*1.8<D2
And so on..

How Do I use Excel Data to Color Shapes in Visio? - Microsoft Visio 2010

I'm trying to create a live display using data that is coming from my excel sheet.
How can I fill a shape based on cell data i. e. 0=red and 1=green?
Thank you
If you have Visio 2010 Professional or Premium, you can use Data Graphics / Color By Value
If you only have the Standard edition, then you can use the Database Wizard to map values in an Excel column to FillForegnd
Alternatively, you can customize your Master shape to set the FillForegnd cell value when the value of value in another cell changes.
Visio does have a default Color Map, with sensible colors from 0 to 13, and shades of gray between 14 and 24.
However, you probably want to specify the RGB values instead.
So, if you have a Shape Data row called Prop.MyDataRow, which has values say between 0 and 5, then you could do the following.
Set the formula of FillPattern to =GUARD(1) - this prevents anyone accidently overwriting the formula, and thus blasting your hard work. The shape will have Solid fill.
Set the formula in FillForegnd to =GUARD(INDEX(Prop.MyDataRow,"0;1;2;3;4"))
Or
Set the formula in FillForegnd to =GUARD(INDEX(Prop.MyDataRow,"RGB(0,0,0);RGB(255,255,255);RGB(255,0,0);RGB(0,255,0);RGB(0,0,255)"))
This formula works for English. The separator character could be different in other languages.
To overcome this, you could use the alternative formula
=GUARD(INDEX(Prop.MyDataRow,RGB(0,0,0)&"~"&RGB(255,255,255)&"~"&RGB(255,0,0)&"~"&RGB(0,255,0)&"~"&RGB(0,0,255),"~"))
Visio will automatically use the RGB separator in your language.
As you can see, there are many ways of achieving the automatic color changing.

Conditional Formatting issue - alternative implementation?

I am having a problem with malfunctioning conditional formatting in Excel 2010, whereby "traffic lights" occasionally have the wrong color. I have several KPIs, with the same "traffic light"-style conditional formatting applied across the cell range: most traffic lights are correct, but some aren't. Monkeying around with, for example, clearing the cell's format and either re-defining it, or copying the format from a different cell, typically helps, but sometimes it does not, and then I am stuck and have to clear the cell's conditional formatting and paste ("hardcode") the appropriate traffic-light image onto it. Can anyone suggest a "traffic lights" implementation that does not depend on Excel's conditional formatting?
I was able to reproduce the apparent rogue behaviour you described and may have a solution for you.
                                                           Columns A correct; column C not-so-much
Column C has a three icon Conditional Format rule as you described using 100 and 75 as the Value and Percentage as the Type. Column A (which appears to work correctly) uses 1 and 0.75 as the Value and Number as the Type.
                                  Raw numerical values instead of percentages in Value text box(es)
So it would appear that Excel 2007 does not handle converting percentages within Conditional Formatting as well as it should.
You shouldn't have to change the display of the values within your worksheet. Just modify the conditional format rules to use the underlying values of your percentages and Number in place of Percentage as the Type.
Delving a little deeper into this showed that using 100% and 75% (as opposed to 100 and 75 sans % symbol) for the Value(s)s while maintaining Percentage as the Type will get Excel to change these on-the-fly to 1 and 0.75 when you leave the corresponding Value text box while retaining Percentage as the Type. This seems contradictory to me, but it does provide the correct green-yellow-red traffic light behaviour.

Resources