LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 167
Default How to track formatting changes

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
"Track Changes" - Prevent turn off track changes to meet SOX regs Tammy Miller Excel Discussion (Misc queries) 2 July 31st 07 11:42 AM
Track Annual Inspection Due Dates Using Conditional Formatting Scatman Excel Worksheet Functions 3 December 7th 05 02:44 PM
How do I create conditional formatting to track due dates Soraiya Excel Worksheet Functions 2 October 14th 05 03:26 PM
Can I use conditional formatting between two sheets to track chan. dawleen Excel Discussion (Misc queries) 2 March 11th 05 03:57 PM
track changes CYeh Excel Discussion (Misc queries) 0 March 10th 05 05:23 AM


All times are GMT +1. The time now is 03:11 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"