mahmed1
Well-known Member
- Joined
- Mar 28, 2009
- Messages
- 2,302
- Office Version
- 365
- 2016
- Platform
- Windows
Hi
I have this function that is used on several sheets and the The range to lookin is in B2:I200 therefore it loops several of times when this function is called or when a cell changes within that range on that sheet
I double on a cell to change its colour and add a value and then this function is called to sum the colour
This works fine but can be clunky at times
Need help speeding it up or using different method
Here is the working Code:
I have this function that is used on several sheets and the The range to lookin is in B2:I200 therefore it loops several of times when this function is called or when a cell changes within that range on that sheet
I double on a cell to change its colour and add a value and then this function is called to sum the colour
This works fine but can be clunky at times
Need help speeding it up or using different method
Here is the working Code:
Code:
Function SumColour(MatchColour As Range, MatchColourRange) As Double
Dim Cell As Range
Application.ScreenUpdating = False
For Each Cell In MatchColourRange
If Cell.Interior.Color = MatchColour.Interior.Color Then
On Error Resume Next
SumColour = SumColour + Cell.Value
On Error GoTo 0
End If
Next Cell
Application.ScreenUpdating = True
End Function