VAB Font Colors

JamesPW

Board Regular
Joined
Nov 4, 2005
Messages
51
Office Version
  1. 2019
Platform
  1. MacOS
An interesting thing I came across and I was wondering if anybody else has seen it and is there a work-around. Here's my code

Function SumByColor(CellColor As Range, rRange As Range)
Application.volatile
Dim cSum As Double
Dim ColIndex As Integer
Dim TempNumber As String

ColIndex = CellColor.Font.ColorIndex
For Each cl In rRange
If cl.Font.ColorIndex = ColIndex Then
cSum = WorksheetFunction.Sum(cl, cSum)
End If
Next cl
SumByColor = cSum
End Function

I have a column of numbers. Some have FontColor = Orange, some have fontColor = Black. I want to sum everything where fontColor=black.
The reference cell/font (ColIndex) is Black
SumByColor will sum the black cells but if I change an orange cell black or a black cell orange SumByColor does not update.
It does recalculate if you change the value of any cell on the sheet.

Can anybody confirm this and is there a way I can get SumByColor to update by changing the font color?
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Can anybody confirm this and is there a way I can get SumByColor to update by changing the font color?
It needs to be an action that will trigger recalculation. Changing the font colour alone will not do it.

You can force recalculation by pressing the f9 key instead of changing a cell value.
 
Upvote 0
With CTRL + ALT + F9 you can enforce recalculation.
F9 will not suffice, I am afraid.
 
Upvote 0
F9 works for me with that code.
 
Upvote 0
F9 will suffice with volatile functions.
Apologies - I did not see the command Application.Volatile.
CTRL + ALT + F9 should work without this command, though.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,959
Messages
6,122,476
Members
449,087
Latest member
RExcelSearch

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