

#Excel how many rows highlighted code#
The COUNTIF function uses the range ($F$2:$F$18) which holds the color code numbers of all the cells and returns the count based on the criteria number. Hence, this color code number is the criteria. The named range in the formula refers to the adjacent cell on the left (in column A) and returns the color code for that cell. The COUNTIF function uses the named range (GetColor) as the criteria. This formula will give you the count of all the cells with the specified background color. In the adjacent cell, use the following formula:.For example, I used Column A, and hence I will use the cells in column ‘A’ only. Make sure you are doing this in the same column that you used in creating the named range. Somewhere below the dataset, give the same background color to a cell that you want to count.If you follow the above process, you would have a column with numbers corresponding to the background color in it. This number is specific to a color, so all the cells with the same background color get the same number. This formula would return 0 if there is NO background color in a cell and would return a specific number if there is a background color. In the cell adjacent to the data, use the formula =GetColor You need to use the reference of the column where you have the cells with the background color.


In the above formula, I have used Sheet1!$A2 as the second argument. Let’s deep dive and see what to do in each of the three mentioned steps.

Using a Custom Function created using VBA.In this tutorial, I will show you three ways to count colored cells in Excel (with and without VBA): #3 Count Colored Using VBA (by Creating a Custom Function).Count Colored Cells using the Color Code.#2 Count Colored Cells Using GET.CELL Function.#1 Count Colored Cells Using Filter and SUBTOTAL.
