One of the most popular posts on this blog is how to become excel conditional formatting rock star. Quite a few commenters there asked me if there is a way to get more than 3 (or 4) conditional formats in excel 2003. Like what you see below:
You can get more than three conditional formats in excel using VBA / macros. Last week I had sometime to put together a simple VBA script using which you can get more than 3 conditional formats in Microsoft excel. Just follow the below 3 steps.
- Download the VBA Macro for getting more than 3 conditional formats
Just copy the VBA Macro cFormat() to your workbook or place it in wherever you keep all your macros. - In your workbook, define 3 named ranges.
data2use: This range contains the cells to be formatted.
conditions2use: This range is identical in shape and size to data2use and contains conditions for the data range start from 1 to n (n being the maximum number of conditional formats your would like to have)
formats2use: This range contains “n” cells each formatted in a way you would like to format the cells in data2use range.See this illustration to understand how these 3 ranges are used to create more than 3 conditional formats:
- Finally hit Alt+F8 (or menu > tools > macro > macros) and run the cFormat macro. The conditional formatting macro you have just downloaded will format the “data2use” range by scanning “conditions2use” range and using the formats in “formats2use” range. If you are curious to see how the VBA script looked like, see the cFormat macro code
- Make sure you have downloaded the workbook with code for getting more than 3 conditional formats in excel
What would you use this trick for? A giant heat map, project plan … ?













5 Responses to “Preparing Profit / Loss Pivot Reports [Part 2 of 6]”
[...] Preparing Pivot Table P&L using Data sheet [...]
[...] Preparing Pivot Table P&L using Data sheet [...]
[...] Preparing Pivot Table P&L using Data sheet [...]
I am not getting sound from the videos. I have checked all the settings and spent several hours searching the Internet to no avail.
Has anyone else had this problem?
Is there anyway to get the Grand Total to be broken out in the same fashion as the items above it? For instance, if you have in column 1, widget a, widget b, and have their sales by month in column 2, I'd like to see the grand total also be by month, for widget a & b combined.
I can't get anything other than a single line for the grand total, rather than the same format as the data above.
Widget A Month Sales
Jan 100
Feb 200
Widget B
Jan 150
Feb 250
Grand total - here I would also like to have Jan, Feb.
Jan 250
Feb 450