Welcome to MSDN Blogs Sign in | Join | Help

Conditional Formatting Trick 2 – How to get an icon in some cells, but not all cells

A few months ago, I described the new features we have added to Excel 2007 in the area of conditional formatting.  One of the new formats we added is called a “icon set” … check out this earlier post for a refresher, but the basic idea is that Excel draws an icon in each cell representing the value of that cell relative to the other cells in the selected range.  Here is a shot from that post.


(Click to enlarge)

The Excel 2007 UI allows you to choose from a wide range of icon sets to apply to your document, but, but, by default, all the cells that you apply conditional formatting to get an icon.  For example, say you had this range of data (measurements of something over 4 time periods) …


… and you applied the “three symbols” icon set using the ribbon …


… you would end up with something like this.  Excel would evaluate all the cells and show an icon in each cell, thereby communicating the value of each cell relative to all cells in the range.


Fair enough, and useful.  One of the bits of beta feedback we have received, though, is it sure would be nice to be able to only show a single icon in a cell if the cell met some criteria – for example, you might just want to see a red “X” in any cells that have a value greater than 80 (because 80 is bad).  While we did not have time to add a single rule to enable that in Excel 2007 (it is on the list for future consideration), it is possible, so I wanted to show folks how.

The first thing we need to do is to set the rule we just applied (the “three symbols” rule) so that the red “X” shows up for values greater than 80.  That’s as simple as tweaking a setting in the Edit Rules dialog.


The next thing to do is to add a second rule that formats values that are less than 80, and set the format to “Automatic” (black text on transparent cells for the default theme). 

Finally, make sure the “Stop If True” flag is turned on.


Once you press OK, you will see that indeed, only the values greater than 80 have an icon.


So how does this work?  Excel evaluates the “Cell Value <80” rule on each cell first, and if the rule is true, Excel stops evaluating the conditions on that cell (that’s what the “Stop If True” flag does) and applies the format, which is set to black on white, so visually nothing changes in those cells.  If the first rule is not true (meaning the cell has a number 80+), Excel evaluates the “three symbols” rule, and puts a red “X” in the cell.  Because the other two symbols (yellow ! and green check mark) have the same condition as the first rule (<80), they are never true and hence they are never seen.  Hopefully that makes sense.

The “Stop If True” setting turns out to be pretty handy, and I expect that users will find all sorts of creative uses beyond just this case.

 

PS updated to fix a typo

Published Tuesday, May 09, 2006 9:52 PM by David Gainer

Comments

# re: Conditional Formatting Trick 2 – How to get an icon in some cells, but not all cells

Wednesday, May 10, 2006 1:44 AM by dido
Multicolor gradients, here I come!!

# re: Conditional Formatting Trick 2 – How to get an icon in some cells, but not all cells

Wednesday, May 10, 2006 3:31 AM by sam
There is hell of variety of icon sets and the way u have described the formating is amazing. They r so colorful.

# Microsoft Excel 2007 Conditional Formating

Wednesday, May 10, 2006 6:04 AM by Melville Thomson's Blog
A lot of you out there like to use Excel for your reporting, there are some great features in Excel 2007...

# re: Conditional Formatting Trick 2 – How to get an icon in some cells, but not all cells

Wednesday, May 10, 2006 5:25 PM by Biff
Just my opinion.........

That 2nd screencap with all those icons applied looks like a real mess. I would not want to see that in any of my spreadsheets.

For my money, a nice fill color works just fine.

# re: Conditional Formatting Trick 2 – How to get an icon in some cells, but not all cells

Wednesday, May 10, 2006 8:01 PM by Harlan Grove
In re Biff's comments,

I think the bigger problem is that the icons appear left-aligned in the cells. I'd be surprised if most users wouldn't associate the icons closest to the numbers with the numbers. A quick glance makes it appear that the value 35 for Measurement 6 in column One has an associated exclamation point rather than a checkmark.

I don't see how icons would be useful without aligning themselves with their corresponding values more closely than with the contents of adjacent cells. Given that it's also useful to have the icons align with each other in each column, the ideal would seem to be for icons to align to the left or right of left or right aligned cells and automatically indent the cell contents to make space. Treat centered and the other horizontal alignments the same as general: align icons on the right for numbers and on the left for the other types (and for general, change cells' horizontal alignment to right or left as appropriate for the cells' type and indent).

This raises the question how these icons would align vertically if they were in cells that wrapped to multiple lines OR were in rows with greater than needed row height. They should either match cells' vertical alignment or always be centered.

# re: Conditional Formatting Trick 2 – How to get an icon in some cells, but not all cells

Thursday, May 11, 2006 8:12 PM by Jean Martineau
I wounder if it would be possible to set the format by specifying a cell ? It would use the format of that cell instead of having to define the format. From this previous post, http://blogs.msdn.com/excel/archive/2005/10/13/480599.aspx, we would have a cell box at the bottom of the Formatring Rule dialogue box.

# re: Conditional Formatting Trick 2 – How to get an icon in some cells, but not all cells

Thursday, May 11, 2006 8:24 PM by Jean Martineau
I am trying back to get a feedback even if it is more related to table. I posted that a while ago:

' I just found out that you can't use personal
' views neither shared a workbook when using
' lists in Excel 2003. Is this working with
' tables in Excel 2007 ?

# re: Conditional Formatting Trick 2 – How to get an icon in some cells, but not all cells

Thursday, May 11, 2006 10:04 PM by Biff
In the 3rd screencap, in what appears to be a tooltip balloon at the bottom right, it says: 3 Symbols (2).

What does (2) mean?

# A bit more on Icon Sets – answers to Biff’s and Harlan’s questions

Friday, May 12, 2006 1:40 AM by Microsoft Excel 2007 (nee Excel 12)
Since a few of the comments that were made on the last post&amp;nbsp; were more easily answered with pictures,...

# re: Conditional Formatting Trick 2 – How to get an icon in some cells, but not all cells

Friday, May 12, 2006 1:45 AM by David Gainer
Jean, by specifying a cell is a good idea - would allowing a choice from cell styles work?  ALso, no, I do not believe personal views in shared workbooks has been changed.

Biff, wrt (2), good question.  Likely a bug.

# re: Conditional Formatting Trick 2 – How to get an icon in some cells, but not all cells

Friday, May 12, 2006 7:08 PM by Jean Martineau
Cell styles could be another option. But what I had really in mind is if I change the format of the cell I specified, it would automatically change the format of the cells matching the rule of the conditional formatting.

# if, then, else with Excel 2007 icon sets | keyongtech

Sunday, January 18, 2009 12:36 PM by if, then, else with Excel 2007 icon sets | keyongtech

# Microsoft Excel Conditional Formatting Trick 2 How to get an icon | debt solutions

New Comments to this post are disabled
 
Page view tracker