Forum Discussion
Counting colored/blank cells in excel - nested macro
Hi all!
Excel: Version 2312 Build 16.0.17126.20132) 64-bit
I am using the https://www.ablebits.com/office-addins-blog/count-sum-by-color-excel/#:~:text=Insert%20the%20code%20of%20the,cell%20with%20the%20target%20color. macro for counting cells by color. This works perfect and produces the correct number. However, I am trying to nest it into a countifs to count if cell is blank and cell is this specific color, but keep getting zero as an answer. What is wrong with my equation?
=COUNTIFS(B2:Q33, "", B2:Q33, CountCellsByColor(B2:Q33, B4))
Count if B2:Q33 is a blank cell and has the color of cell.
B4 = the cell with the specific color.
I tried the RGB method prior to the macro - but it kept producing zero as an answer.
I changed this line of the code
If indRefColor = cellCurrent.Interior.Color Then
to
If indRefColor = cellCurrent.Interior.Color And IsEmpty(cellCurrent) Then
and CountCellsByColor returns the intended result if i correctly understand what you are looking for.
2 Replies
- OliverScheurichGold Contributor
I changed this line of the code
If indRefColor = cellCurrent.Interior.Color Then
to
If indRefColor = cellCurrent.Interior.Color And IsEmpty(cellCurrent) Then
and CountCellsByColor returns the intended result if i correctly understand what you are looking for.
- blondiedaniCopper Contributor
Thank you so much!!!