Automatically run a macro when I manually change a cell colour

FuzzyOwl

New Member
Joined
Jan 10, 2020
Messages
1
Office Version
  1. 2016
Platform
  1. Windows
Hi,

I'm using a spreadsheet to track the cases I'm working on at work. I've got a column (G) in which I colour code my cases by urgency. Red is immediate action, orange is urgent action etc. I change these manually when something comes in that warrants a change in a case's urgency (i.e. a screaming email from my boss or the client).

I found a neat little macro online, which has the name "CountCcolor" which looks like this:

VBA Code:
Function CountCcolor(range_data As Range, criteria As Range) As Long
    Dim datax As Range
    Dim xcolor As Long
xcolor = criteria.Interior.ColorIndex
For Each datax In range_data
    If datax.Interior.ColorIndex = xcolor Then
        CountCcolor = CountCcolor + 1
    End If
Next datax
End Function

Essentially it allows me to keep track of how many cases I have of each urgency level, which is nice. Right now I have 3 marked as red, 2 as orange etc. Problem is, it doesn't automatically update the count when I change a cell colour. So if I work on one of those red ones and change it to orange, I now have 2 red and 3 orange, but the count won't update unless I manually make the macro run by clicking in the cells where the formula is.

I'll be honest, I'm not great at this kind of thing, and it's not something I can devote much work time to, so I'm stuck for a solution. Is there any way I can set things up so that this macro runs automatically when I change the colour of a cell?

Thanks in advance
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Hi & welcome to MrExcel
Changing the colour of a cell will not trigger anything. One option is to use a code that will cause the sheet to recalculate everytime you select a new cell, but depending on your sheet, this may cause more problems than it's worth.
 
Upvote 0

Forum statistics

Threads
1,223,898
Messages
6,175,274
Members
452,628
Latest member
dd2

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top