Macros lag

%3CLINGO-SUB%20id%3D%22lingo-sub-1995844%22%20slang%3D%22en-US%22%3EMacros%20lag%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1995844%22%20slang%3D%22en-US%22%3E%3CP%3EHello!%20May%20someone%20give%20advice%20on%20how%20to%20speed%20up%20the%20%22calculating%20thread%22%20of%20a%20workbook%20containing%20this%20macro%3F%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThank%20you%20in%20advance%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EFunction%20ColorSum(MatchColor%20As%20Range%2C%20sumRange%20As%20Range)%3C%2FP%3E%3CP%3EApplication.Volatile%20True%3CBR%20%2F%3EDim%20cell%20As%20Range%3CBR%20%2F%3EDim%20myColor%20As%20Long%3CBR%20%2F%3EmyColor%20%3D%20MatchColor.Cells(1%2C%201).Interior.Color%3CBR%20%2F%3EFor%20Each%20cell%20In%20sumRange%3CBR%20%2F%3EIf%20cell.Interior.Color%20%3D%20myColor%20Then%3CBR%20%2F%3EColorSum%20%3D%20ColorSum%20%2B%20cell.Value%3CBR%20%2F%3EEnd%20If%3CBR%20%2F%3ENext%3C%2FP%3E%3CP%3EEnd%20Function%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1995844%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMacros%20and%20VBA%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Occasional Visitor

Hello! May someone give advice on how to speed up the "calculating thread" of a workbook containing this macro? 

 

Thank you in advance 

 

Function ColorSum(MatchColor As Range, sumRange As Range)

Application.Volatile True
Dim cell As Range
Dim myColor As Long
myColor = MatchColor.Cells(1, 1).Interior.Color
For Each cell In sumRange
If cell.Interior.Color = myColor Then
ColorSum = ColorSum + cell.Value
End If
Next

End Function

0 Replies