Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I wrote a user-defined function that sums all cells in a given range that
have the same color fill as the calling cell. The code works great except when the user changes the fill color of a cell. The formula will not update because technically no values changed. How can I get around this? I am providing the code for others to use. ------------------------------------------------------------------------------------------ Function sumColor(range1 As Range, Optional range2 As Range, Optional range3 As Range, Optional range4 As Range) sumColor = 0 For Each cell In range1 If cell.Interior.ColorIndex = Application.ThisCell.Interior.ColorIndex Then sumColor = sumColor + cell.Value End If Next cell If Not range2 Is Nothing Then For Each cell In range2 If cell.Interior.ColorIndex = Application.ThisCell.Interior.ColorIndex Then sumColor = sumColor + cell.Value End If Next cell End If If Not range3 Is Nothing Then For Each cell In range3 If cell.Interior.ColorIndex = Application.ThisCell.Interior.ColorIndex Then sumColor = sumColor + cell.Value End If Next cell End If If Not range4 Is Nothing Then For Each cell In range4 If cell.Interior.ColorIndex = Application.ThisCell.Interior.ColorIndex Then sumColor = sumColor + cell.Value End If Next cell End If End Function ------------------------------------------------------------------------------------------ Thanks, Pflugs |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
"Track Changes" - Prevent turn off track changes to meet SOX regs | Excel Discussion (Misc queries) | |||
Track Annual Inspection Due Dates Using Conditional Formatting | Excel Worksheet Functions | |||
How do I create conditional formatting to track due dates | Excel Worksheet Functions | |||
Can I use conditional formatting between two sheets to track chan. | Excel Discussion (Misc queries) | |||
track changes | Excel Discussion (Misc queries) |