AutoCalculate on Custom Function

Oscargriz

New Member
Joined
Oct 22, 2008
Messages
14
I have downloaded a bit of code that would sum a range based on the background color. The "Sum" portion of the function works on change now that I added "Application.Volatile" to the top of the code, however if I change the color of a cell, it doesn't recalculate.

I considered doing a Change Event, however I'm not sure how I need to reference the background color as the item that is changing. Any help here would be appreciated.
 

Some videos you may like

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
36,151
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2010
Platform
  1. Windows
  2. MacOS
Changing the background colour of a cell does not trigger any events you can trap, which is the main reason I always advise against this sort of setup. It's much better to have the contents of the cell (or another cell) as an indicator and use that to colour the cells. Your functions can then work directly off the cell contents.
 

Oscargriz

New Member
Joined
Oct 22, 2008
Messages
14
Would it be possible then to loop the formula so that any time a new cell is made active, the formula recalculates?
 

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
36,151
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2010
Platform
  1. Windows
  2. MacOS
You could make the SelectionChange event of the worksheet issue a Calculate command, if you really want to stick with this method.
 

Watch MrExcel Video

Forum statistics

Threads
1,123,307
Messages
5,600,869
Members
414,411
Latest member
Snowmanaus

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
Top