Count cells based on color
This article explains how to count cells highlighted with Conditional Formatting (CF). The image above shows data in cell range B2:C11, column C has Conditional Formatting applied based on the following CF formula.
What's on this page
- How to apply Conditonal Formatting
- How to count cells based on conditionally formatted background color [Excel 365]
- How to count cells based on conditionally formatted background color [Previous Excel versions]
- Count cells based on conditionally formatted background color using Filter tool and SUBTOTAL function [Excel 365]
- Get excel *.xlsx file
- Count cells based on background color programmatically - not CF
- Count unique distinct values by cell color - not CF
- How to change cell background color
- How to count cells with a specific background color (Excel 365)
- How to count cells with a specific background color (earlier Excel versions)
- How to count cells based on criteria font color, cell color, and bold/italic (VBA)
- How to count unique distinct cell values based on criteria font color, cell color, and bold/italic (VBA)
- Get Excel *.xlsm file
A Conditional Formatting formula allows you to create your own condition or criteria if the built-in conditions are not enough.
As far as I know, you can only count cells with cell background color, not font color or bold/italic etc. It is also not possible to count cells highlighted with Conditional Formatting using VBA code, however, you can count cells manually formatted using VBA code.
If you know how to apply Conditional Formatting based on a formula you can skip these steps and go to the next section right now. Here are the steps to apply Conditional Formatting to a cell range.
1. How to apply Conditional Formatting
These steps explain how to apply Conditional Formatting to a cell range based on a formula.
- Select the cell range you want to highlight.
- Go to tab "Home" on the ribbon.
- Press with left mouse button on "Conditional Formatting" button on the ribbon.
- Press with left mouse button on "New Rule...", a dialog box appears. See the image above.
- Type your formula in "Format values where this formula is true:".
- Press with left mouse button on "Format..." button and another dialog box appears.
- Press with left mouse button on tab "Fill" on the top menu.
- Pick a color.
- Press with left mouse button on "OK" button.
- Press with left mouse button on "OK" button again.
2. How to count cells with a specific cell background color [Excel 365]
These steps show how to count highlighted cells.
- Select any cell in the data set.
- Press CTRL + T to open "Create Table" dialog box.
- Press with left mouse button on the checkbox accordingly based on the layout of your data set.
- Press with left mouse button on "OK" button to create the Excel Table.
- Press with left mouse button on the arrow next to the column name you want count cells in.
- A pop-up menu appears, press with left mouse button on "Filter by Color". Another pop-up menu appears, press with left mouse button on the color you want to sort by.
- The Excel Table now shows only the cells with the selected background color.
- Select any cell in the Excel Table and a new tab on the ribbon shows up named "Table Design", press with left mouse button on that tab to select it.
- Press with left mouse button on the checkbox "Total Row" located on the ribbon, see image above. A new row appears below the Excel Table values.
- Press with left mouse button on the number next to total. An arrow appears next to the number, press with left mouse button on that arrow. See image above.
- Press with left mouse button on "Count".
The number of cells highlighted with a given cell background color using conditional formatting is shown in cell C12.
3. How to count cells with a specific cell color [Previous Excel versions]
- Press with right mouse button on on a cell that has a background color you want to count. A pop-up menu appears.
- Press with left mouse button on "Sort" and another pop-up menu shows up.
- Press with mouse on "Put Selected Cell Color On Top".
- Select all colored cells.
- Excel returns the count of your selection in the lower right corner of your Excel window. See image above.
4. Count cells with a specific cell background color using the FILTER tool and the SUBTOTAL function [Excel 365]
This section demonstrates how to count cell background color based on Conditional Formatting using the Filter tool. The Filter tool is built-in to Excel, the following steps show you how.
- Select any cell in your data set.
- Press shortcut keys CTRL + SHIFT + L to apply the Filter feature to your data set. You know it is there when you have arrows next to your column names. You can also go to tab "Data" on the ribbon and press with left mouse button on "Filter" button to apply it.
- Press with left mouse button on the arrow in the column you want to count a specific cell background color. A pop-up menu appears.
- Press with mouse on "Filter by Color" and another pop-up menu appears.
- Press with mouse on the color you want to filter by, see image above.
The following formula will count visible cells in cell range C3:C11 that is not empty. I entered it in cell C13.
The SUBTOTAL function allows you to perform many different calculations based on the first argument. It is also able to perform these calculations to filtered values in contrast to the regular SUM, AVERAGE, COUNT and COUNTA functions.
SUBTOTAL(function_num, ref1, ...)
Recommended reading
- Conditional Formatting (Excel easy)
- Use conditional formatting to highlight information (Microsoft Ofiice)
- Using If/Then in Conditional Formatting in Excel
6. Count cells based on background color programmatically
This article demonstrates a VBA macro that counts cells based on their background color.
I got a question about counting background colors in a cell range. Excel uses two different properties to color cells and they are ColorIndex and Color property.
The ColorIndex property has 56 different colors, shown below.
The color property holds up to 16 777 216 colors. I tried to color 16 columns with 1048576 rows each (16 * 1048576 = 16 777 216) using the color property but excel returned this error after 65277 cells.
6.1. VBA code
The following macro lets you count background colors, however, note that it won't count cells colored with conditional formatting.
'Name macro Sub CountColors() 'This macro counts background colors in cell range 'https://www.get-digital-help.com/2017/03/30/count-colored-cells/ 'Dimension variables and declare data types Dim IntColors() As Long, i As Integer Dim chk As Boolean 'Ask user for a cell range and save the output to range variable rng Set rng = Application.InputBox("Select a cell range to count colors: ", , , , , , , 8) 'Redimension array variable IntColors ReDim IntColors(0 To 2, 0) 'For Each ... Next statement For Each cell In rng chk = False For c = LBound(IntColors, 2) To UBound(IntColors, 2) If cell.Interior.ColorIndex = IntColors(0, c) And cell.Interior.Color = IntColors(1, c) Then IntColors(2, c) = IntColors(2, c) + 1 chk = True Exit For End If Next c If chk = False Then IntColors(0, UBound(IntColors, 2)) = cell.Interior.ColorIndex IntColors(1, UBound(IntColors, 2)) = cell.Interior.Color ReDim Preserve IntColors(2, UBound(IntColors, 2) + 1) End If Next cell ReDim Preserve IntColors(2, UBound(IntColors, 2) - 1) Set WS = Sheets.Add WS.Range("A1") = "Color and count" WS.Range("B1") = "ColorIndex" WS.Range("C1") = "Color" j = 1 For i = LBound(IntColors, 2) To UBound(IntColors, 2) If IntColors(2, i) <> 0 Then WS.Range("A1").Offset(j).Interior.ColorIndex = IntColors(0, i) WS.Range("A1").Offset(j).Interior.Color = IntColors(1, i) WS.Range("A1").Offset(j) = IntColors(2, i) WS.Range("A1").Offset(j, 1) = IntColors(0, i) WS.Range("A1").Offset(j, 2) = IntColors(1, i) j = j + 1 End If Next i End Sub
6.2. Where do I copy and paste the VBA code?
- Select and copy code above (Ctrl+c).
- Open VB Editor (Alt+F11).
- Insert a new module to your workbook.
- Paste code to code module.
Note, save your workbook with file extension *.xlsm (macro-enabled workbook) to keep the code attached to your workbook.
6.3. Instructions
- Press Alt + F8 to open the macro dialog box, it shows a list of macros currently in your open workbooks.
- Press with mouse on macro CountColors with left mouse button to slect it.
- Press the "Run" button on the dialog box.
- Select a cell range you want to count.
The macro then creates a new sheet with cells in a column colored and their count, see picture below.
Value -4142 means No fill and -4105 is the default color (white).
There is no way to quickly transfer cell formatting properties to an array so the macro is quite slow, it reads a cell's property one by one. I don't recommend using this with larger cell ranges unless you are prepared to wait for a while.
7. Count unique distinct values by cell color - not CF
This article demonstrates a User Defined Function (UDF) that counts unique distinct cell values based on a given cell color. A UDF is an Excel Function that you can build yourself which is very handy if there isn't a built-in function that can do it for you.
A UDF is built of VBA code, VBA stands for Visual Basic for Applications. Microsoft Excel has a built-in Editor named Visual Basic Editor that allows you to create macros and UDFs. You will be surprised how easy it is to start building your own macros.
The image above shows the following formula in cell E4:
The first argument is the cell range. The second argument is a single cell with a color you want to use as a condition. Cell D4 has an interior color red.
The formula in cell E4 uses the color of cell D4 to find cells in cell range B3:B22 with the same color. When a matching color is found the cell value is analyzed and possibly counted in order to count all unique distinct values.
For example, the formula returns 6 in cell E4 because there are 6 numbers in red cells and they all are unique. Cell E6 returns 4, numbers in green cells are 87, 84, 78, 75, 78 and 84. Number 84 and 78 have duplicates. Unique distinct values are all values except duplicates are merged into one single value. That leaves us four numbers: 87, 84, 75 and 78.
The formula above won't work until you have copied the VBA code below and pasted it to a code module in your workbook.
User Defined Syntax
CountC(rng As Range, Cell As Range)
Arguments
rng | Required. A cell reference to a cell range that you want to count cells based on cell color. |
Cell | Required. A cell reference to one cell containing the color you want to count. |
VBA code
VBA code is easy to learn, I highly recommend the macro recorder if you are new to VBA. It lets you record a macro based on your actions. Start the recording, perform your actions and then stop the recording. Now, look at the code Excel created.
You can find the "Macro recorder" on the "Developer" tab, if that tab is missing on the ribbon you need to enable it. Then go to the VB Editor to check out the code Excel created for you. See instructions below on how to show the Visual Basic Editor.
I have commented each line in the UDF displayed below, you can copy those lines as well. The apostrophe is a character that allows you to comment your code, it will be ignored when the UDF or macro is started.
'Name the User Defined Function and it's parameters Function CountC(rng As Range, Cell As Range) 'Dimension variables and declare data types Dim CellC As Range, ucoll As New Collection 'Iterate through each cell in range object rng using variable CellC For Each CellC In rng 'Check if cell color is equal to second parameter If CellC.Interior.Color = Cell.Interior.Color Then 'Enable error handling On Error Resume Next 'Check if the number of characters are larger than zero and if so add the cell value to collection ucoll If Len(CellC) > 0 Then ucoll.Add CellC, CStr(CellC) 'Disable error handling On Error GoTo 0 End If 'Continue with next cell Next CellC 'Return values in collection variable ucoll to UDF CountC = ucoll.Count End Function
I do recommend commenting your VBA code, it will be a time saver next time you need the macro/UDF and need to do modifications.
Where to put the code?
The image above shows the Visual Basic Editor. The Project Explorer is to the left and an empty window is to the right. There is a top menu and some buttons below the top menu.
The image shows what to press with left mouse button on in order to create a new module in your workbook for the User Defined Function.
- Copy above VBA code.
- Press shortcut keys Alt + F11 to open the Visual Basic Editor. The Project Explorer window is to the left, it allows you to select which workbook and module to use.
- Press with left mouse button on "Insert" on the top menu.
- Press with left mouse button on "Module" to create a code module in your workbook.
- Paste to code window, see image above.
- Exit VB Editor and return to Excel.
Recommended articles
8. How to change cell background color
Excel lets you color cells using the "Fill Color" tool located on tab "Home" on the ribbon.
- Select the cell or cell range you want to apply a different background color to.
- Go to tab "Home" on the ribbon.
- Press with left mouse button on "Fill Color" button and a pop-up menu appears.
- Pick a color.
Sometimes it can be useful to know the number of cells filled with a specific background color. Excel 365 makes this really easy, there is a work-around for older Excel versions that I will show in this article as well.
9. How to count cells with a specific background-color (Excel 365)
The Excel Table allows you to filter and count cells with a specific background color.
- Select any cell in the data set.
- Press shortcut keys CTRL + T to show the "Create Table" dialog box.
- Enable the checkbox if your data has header names.
- Press with left mouse button on the "OK" button to convert cell range to an Excel Table.
- Press with left mouse button on the arrow next to the header name which corresponds to the column you want to filter.
- A pop-up menu appears, press with left mouse button on "Filter by Color".
- Another pop-up menu appears, press with left mouse button on the color you want to filter by.
- Select any cell in the Excel Table. A new tab shows up on the ribbon named "Table Design".
- Press with mouse on the tab "Table Design" on the ribbon.
- Press with mouse on checkbox "Total Row", see image above.
A new cell appears below the Excel Table, see image above.
- Select the new cell. An arrow appears next to the number, see image above.
- Press with left mouse button on the "Arrow", a pop-up menu appears.
- Press with left mouse button on "Count".
The number in the cell changes, it now shows the total count of cells based on the filter we applied. The formula bars hows this formula:
The SUBTOTAL function is able to count visible cells in a filtered table, number 103 stands for COUNT and [Numbers] is a structured reference to data in column Numbers.
Structured references appear automatically when you reference data in an Excel Table, in this case, Excel created this for us when we enabled checkbox "Total row" in a previous step.
10. How to count cells with a specific background-color (earlier Excel versions)
- Press with right mouse button on on a cell that has the background color you want to filter by. A pop-up menu appears.
- Press with mouse on "Sort", another pop-up menu shows up.
- Press with left mouse button on "Put selected Cell color on top".
The data is now sorted by cell color, see image above. Select all cells with the background color you want to count, they should now be adjacent to each other and sorted on top.
Excel counts the selected cells for and shows the number in the lower right corner of your Excel window.
11. Count cells by cell font properties (font color, cell color, bold or italic)
The image above demonstrates a User defined function (UDF) in cell D3 that counts cells in column A based on the cell formatting in cell C3. The font properties are color, cell color and bold/italic.
How difficult would it be to make it count colour alone (so not unique values) and/or use cell font colour or other features also (bold for example)?Excel has some quick green (with green text) and red (with red text) preset formats that people often use in either conditional formats or by manual application and although the unique values is very useful in a lot of cases this is even more detailed than required for just a count of the formatted conditions.Awesome site by the way, it's been invaluable to me lately!
Cheers.
Custom function in cell D3:
The user defined function counts how many times the font properties in cell C3 match each cell in the cell range A1:A20.
User defined function
'Name UDF and dimension parameters and declare their data types Function CountC(rng As Range, Cell As Range) 'Dimension variables and declare data types Dim CellC As Range, ucoll As New Collection, i As Single 'Save 0 (zero) to variable i i = 0 'Iterate through each cell in parameter rng using variable CellC For Each CellC In rng 'Check if cell background color matches parameter Cell's cell background color If CellC.Interior.Color = Cell.Interior.Color And _ CellC.Font.Bold = Cell.Font.Bold And _ CellC.Font.Italic = Cell.Font.Italic And _ CellC.Font.ColorIndex = Cell.Font.ColorIndex Then 'Add 1 to the number in variable i i = i + 1 End If 'Continue with next cell Next CellC 'Return number stored in variable i to UDF. CountC = i End Function
Where to put the VBA code?
- Copy VBA code.
- Press Alt + F11 to open the VB Editor.
- Press with left mouse button on "Insert" on the top menu, a pop-up menu appears. See image above.
- Press with left mouse button on "Module" to insert a module to your workbook. The module appears in the "Project Explorer", in this case, named Module1.
- Paste code to code window.
12. Count unique distinct cells by cell font properties (font color, cell color, bold or italic)
The image above shows a user defined function in cell D3 that counts unique distinct values in cell range A1:A20 based on the cell formatting in cell C3. This UDF also checks font color, cell color and bold/italic.
The formula in cell D3 returns 3 because the values in cell A5, A10, A16 and A17 match the cell formatting in cell C3. The values are 24, 5, 24 and 17. However, the unique distinct values are 24, 5 and 17. 3 numbers and 3 is returned to cell D3.
Custom function in cell D3:
The user defined function matches the font properties in cell C3 with each cell in cell range A1:A20, then counts unique distinct values in those matching cells.
User defined function
Function CountUDC(rng As Range, Cell As Range) Dim CellC As Range, ucoll As New Collection For Each CellC In rng If CellC.Interior.Color = Cell.Interior.Color And _ CellC.Font.Bold = Cell.Font.Bold And _ CellC.Font.Italic = Cell.Font.Italic And _ CellC.Font.ColorIndex = Cell.Font.ColorIndex Then On Error Resume Next If Len(CellC) > 0 Then ucoll.Add CellC, CStr(CellC) On Error GoTo 0 End If Next CellC CountUDC = ucoll.Count End Function
Get Excel file
Recommended reading
Built-in conditional formatting
Data Bars Color scales IconsHighlight cells rule
Highlight cells containing stringHighlight a date occuring
Conditional Formatting Basics
Highlight unique/duplicates
Top bottom rules
Highlight top 10 valuesHighlight top 10 % values
Highlight above average values
Basic CF formulas
Working with Conditional Formatting formulasFind numbers in close proximity to a given number
Highlight empty cells
Highlight text values
Search using CF
Highlight records – multiple criteria [OR logic]Highlight records [AND logic]
Highlight records containing text strings (AND Logic)
Highlight lookup values
Unique distinct
How to highlight unique distinct valuesHighlight unique values and unique distinct values in a cell range
Highlight unique values in a filtered Excel table
Highlight unique distinct records
Duplicates
How to highlight duplicate valuesHighlight duplicates in two columns
Highlight duplicate values in a cell range
Highlight smallest duplicate number
Highlight more than once taken course in any given day
Highlight duplicates with same date, week or month
Highlight duplicate records
Highlight duplicate columns
Highlight duplicates in a filtered Excel Table
Compare
Highlight missing values between to columnsCompare two columns and highlight values in common
Compare two lists of data: Highlight common records
Compare tables: Highlight records not in both tables
How to highlight differences and common values in lists
Compare two columns and highlight differences
Min max
Highlight smallest duplicate numberHow to highlight MAX and MIN value based on month
Highlight closest number
Dates
Advanced Date Highlighting Techniques in ExcelHow to highlight MAX and MIN value based on month
Highlight odd/even months
Highlight overlapping date ranges using conditional formatting
Highlight records based on overlapping date ranges and a condition
Highlight date ranges overlapping selected record [VBA]
How to highlight weekends [Conditional Formatting]
How to highlight dates based on day of week
Highlight current date
Misc
Highlight every other rowDynamic formatting
Advanced Techniques for Conditional Formatting
Highlight cells based on ranges
Highlight opposite numbers
Highlight cells based on coordinates
Excel categories
47 Responses to “Count cells based on color”
Leave a Reply
How to comment
How to add a formula to your comment
<code>Insert your formula here.</code>
Convert less than and larger than signs
Use html character entities instead of less than and larger than signs.
< becomes < and > becomes >
How to add VBA code to your comment
[vb 1="vbnet" language=","]
Put your VBA code here.
[/vb]
How to add a picture to your comment:
Upload picture to postimage.org or imgur
Paste image link to your comment.
Contact Oscar
You can contact me through this contact form
Oscar,
A little off topic question, but I am thinking outside the box a little.
I have two charts that display different data sets for the same projects. I want the formatting of the series (projects) to be the same on each chart so they are recognisable. Could similar VBA code be used to format the fill colour on the charts based on how you colour the series names in the data tables?
Mark Graveson,
read this post:
Format fill color on a column chart based on cell color
Oscar,
Thanks again for the answer in the other blog post. I'll also be looking for the response to Dave's question!
Mark.
[…] Mark Graveson asks: […]
Oscar, great function! How difficult would it be to make it count colour alone (so not unique values) and / or use cell font colour or other features also (bold for example) ? Excel has some quick green (with green text) and red (with red text) preset formats that people often use in either conditional formats or by manual application and althought the unique values is very useful in a lot cases this is even more detailed than required for just a count of the formatted conditions. Awesome site by the way, it's been invaluable to me lately! Cheers..
Dave,
great question! I am working on a blog post, check it out next week.
Dave and Mark Graveson,
Read this post:
Count cells by cell and font color
Hi,
Really brilliant UDF fella! one thing tho...
I have used it for a spreadsheet of mine and have coune accross a problem. When using the code to count the colour red its is also counting cells that are blank (colour wise) as red? I have got around it using another formular but wondered if there was anything you cound do?
thanks
James,
I don´understand, can you upload an example file?
This is a really awesome tutorial and MUCH needed function!
I wonder if there is a way for it to work in Excel 2013? I tried it with a basic color and with Excel's Conditional Formatting, and no luck with either, unfortunately.
Andrew,
There is something wrong with the 2010 version also.
Oh! So, does that mean you are working on it, or have you abandoned this function? It would be really awesome and worth pursuing. So many people could use this.
Anyway the tutorial is well done, so if the VBA code gets fixed, please do post an update! Should get many website hits for you because its such a useful analysis.
Thanks.
I am trying to do this with multiple columns.
Example:
I have an employee schedule that will highlight a color per half hour if it is between the employee schedule.
Rows: Employee's
Columns: Time by half hour
I want to count how many employees are working during each half hour by counting the highlighted cell. This formula works for one cell but then i get errors with others. it says "Formula emits adjacent cells"
Any idea what that means?
I try it same, but it got output as 0.
And i check with different cells.
Can any one help me.
Note: If i select empty cell i get color not found.
Same here, I got "color not found even after changing the color to match the picture.
I have found that the script only works for one conditional formatting rule at a time. If you select a group of cells that have different rules, the script only gives the result of the first rule. Does anyone know how to make it work with more than one rule?
Hi
This works great but for two cells or more, but doesn't work for a single cell. It always says 0 regardless. Is there an easy change to make this work for one cell i.e. does this cell have the conditional formatting active?
Brett,
The macro is not working as I thought it would and I don´t know how to fix it.
Hi Oscar and Brett,
Your code is just fine. I used conditional formatting to color code a matrix (imagine a dashboard with just colors in empty cells) and used your code to count the # of a particular color in a column. It works!! yay!! Just wanted to let you know.
good day
I added some more numbers in the column and colored another several cells ,
on d2 I changed =countcfcells(a2:a17,c2) to =countcfcells(a2:a24,c2)
then I received #value!
only the first quantity works.
a2:a17
and not a2:a24
I try to understand.
for several hours -no success.
can you help ?
thanks
yosef
This is much more succinct than Chip Pearson's monster code. However, it does not work for Excel 2013. Even your workbook, as soon as it's opened the 10 changes to #VALUE!
Furthermore it is unclear how you colored the blank cell - did you simply fill with a background of red? Don't think so but you did not explain. Sorry we aren't mind readers - smile. If you did not, how did you conditionally format that blank cell to be red? I tried various ways and none worked. This is frustrating as hell not to be able to simply count the colored cells from CF.
Thanks for any assistance,
Mort in Dallas
Hi mate, I am trying to do the Conditional format colour count and I have pasted and tried to use the function. But when I run the function it says that the colour was not found. Can you please help me with that.
okey i had used this code it gives me a error
Compile Erorr :
Syntax error:
(Module 1 5:0)
Function CountCFCells(rng As Range, C As Range)
Dim i As Single, j As Long, k As Long
Dim chk As Boolean, Str1 As String, CFCELL As Range
chk = False
For i = 1 To rng.FormatConditions.Count
If rng.FormatConditions(i).Interior.ColorIndex = C.Interior.ColorIndex Then
chk = True
Exit For
End If
Next i
j = 0
k = 0
If chk = True Then
For Each CFCELL In rng
Str1 = CFCELL.FormatConditions(i).Formula1
Str1 = Application.ConvertFormula(Str1, xlA1, xlR1C1)
Str1 = Application.ConvertFormula(Str1, xlR1C1, xlA1, , ActiveCell.Resize(rng.Rows.Count, rng.Columns.Count).Cells(k + 1))
If Evaluate(Str1) = True Then j = j + 1
k = k + 1
Next CFCELL
Else
CountCFCells = "Color not found"
Exit Function
End If
CountCFCells = j
End Function
The format can count only greater than or less than conditional format only. can't count between condition format.
EX.
Red colour ratio = 1 to 7
Yellow colour ratio = 8 to 11
Green colour ratio = 12 to 15
Blue colour ratio = above 15
Do you know of anyway to count up only the visable rows? I have some filtered data and I need to just get the visable rows, do a count of each color, and get the average.
Hello, the formula works perfectly if conditional formatting is "cell is greater than".
But when you use a formula like this in conditional formatting: "=if(A1=1,true,false) the formula countofcells returns "#VALUE!"
Any ideas how to make it work with more complex conditional formatings ???
Hi,
This works perfectly in columns, but what part do I have to change in VBA to count in rows?
Thanks in advance for your advice.
I want to add a pivot table and have a count based on color cells.
Example, I have highlighted in red some cells vs others and want to only have the pivot table count the red cells rather than everything.
Elvia,
I recommend pivot table filters:
https://support.office.com/en-us/article/Filter-data-in-a-PivotTable-cc1ed287-3a97-4e95-b377-ddfafe79fa8f
I have the same question as Steven, the columns work great, but I can't get it to work on rows. What do I need to do.
Thanks
Tommy and Steven,
Don't use the macro in this post, it is not working.
I recommend you tweak and use your conditional formatting formula to count conditionally formatted cells.
Oscar
Thanks for the quick reply, but when I do the same thing you sent me it doesn't work. How can I send you my file so you can see what i'm trying to do. I don't understand how to tweak my conditional formatting formula to count the cells.
Thanks again
Oscar, your code is currently working when I opened the file and I think it will continue to work on the file that I need it to. However, I need to adjust the code to count rows not columns, what portion would I modify in order to do so?
Thanks in Advance
Shan
The code is not reliable, I recommend you don't use it.
Hi Oscar,
I tried to change the conditional formatting ie:format only cells that contain(cell value = 0) and the result is zero though the red cells are 6.
Please help.
Thanks you
rechel
Yes, the macro is not working. Do not use it.
I have created a table containing conditionally formatted cells to represent the following;
Red scores zero for non compliance
Amber scores 5 for observation
Green scores 10 for compliance
So my table represents the audit results based upon 10 questions whereby 10/10 would show 10 greens
9/10 would be 9 green and one red
I want to show these results in a stacked bar chart whereby the Stack represents the 10 questions but if for example q8 is red then I want my chart to show this !!!
I cannot fathom out how to do this as whatever I try affects the whole series whereas I want it to only apply to each individual part of the stack for each audit
Please help
Many thanks
Mark
Hello, I am trying to figure out how to return a value if a cell is highlighted a colour.
I.E If I have a spreadsheet and I highlight a cell red which contains the word 'apple' is there a way to return this value?
Jason,
You can't return a value based on conditional formatting using a formula, as far as I know, but, conditional formatting is applied using a given condition or criteria. You can use the same condition or criteria to create a formula that returns a specific cell value.
You can't return a value with a formula if a cell is highlighted manually.
Hi,
Do you know if there is a way to count conditionally colored cells across a specific row?
Thanks
Rachel
Rae Rae
Yes and no.
You can't count conditonally formatted cells, however, you can count cells using the same conditonal formatting formula.
Here is an example:
How to count the top 10 numbers in a cell range per row
Hello,
I am trying to get a formula which will help me to count the numbers of conditionally formated colour cells in single row 1row at time.
Each cell in a row belonging to a column which has a conditional format for highlighting of Top or Bottom 10 figures in a column respectively. Can their be specific formula for this?
Regards
Shashi
Shashi,
Great question!
Here is the answer:
How to count the top 10 numbers in a cell range per row
Hi There,
How to count the conditionally formatted cell with color RED?
All the above method seems not working.
Pls guide...
Thanks.
Arun,
What Excel version do you use?
Hi,
Excel Macro-Enabled Workbook
Hi,
Excel Macro-Enabled Workbook