Counting cells by colour

scooby51

New Member
Joined
Apr 6, 2012
Messages
15
Hi All,

I am wondering if there is formula whereby I can count cells based on their colour?
 

RasGhul

Well-known Member
Joined
Jul 15, 2016
Messages
608
Hi,

Right Click on your Sheet tab, View Code. This will open the VBA window for this sheet code.

Paste;

Code:
Sub Listcolors()

For Each C In Selection


    C.Offset(0, 1).Value = C.Interior.Color


Next C




End Sub
Highlight the the range of cells with the color, then run the macro. Avoid highlighting the whole column only the range you need.

The macro will populate the color number in the cells to the right, which you can use with countif & sumifs etc.
 

Forum statistics

Threads
1,081,537
Messages
5,359,380
Members
400,526
Latest member
Brook1083

Some videos you may like

This Week's Hot Topics

  • VBA (Userform)
    Hi All, I just would like to know why my code isn't working. Here is my VBA code: [CODE=vba]Private Sub OKButton_Click() Dim i As Integer...
  • List box that changes fill color
    Hello, I have gone through so many pages trying to figure this out. I have a 2020 calendar that depending on the day needs to have a certain...
  • Remove duplicates and retain one. Cross-linked cases
    Hi all I ran out of google keywords to use and still couldn't find a reference how to achieve the results of a single count. It would be great if...
  • VBA Copy and Paste With Duplicates
    Hello All, I'm in need of some input. My VBA skills are sub-par at best. I've assembled this code from basic research and it works but is...
  • Macro
    is it possible for a macro to run if the active cell value is different to the value above it
  • IF DATE and TIME
    I currently use this to check if date has passed but i also need to set a time on it too. Is it possible? [CODE=vba]=IF(B:B>TODAY(),"Not...
Top