I want to define a function that can sum all cells' value and then return the color of sum number
For example, A1:A10 is 1 to 10, the sum of A1:A10 is 55, and at the same time the interior color of another cell would change to the color that the colorindex
Function iSumColor(r As Range, v As Range) As Double
Dim q As Range
Dim result As Double
result = 0
For Each q In r
result = result + q.Value
Next
Dim c As Range
For Each c In q
c.Interior.ColorIndex = result
Next
iSumColor = result
End Function
and I input the function "=iSumColor(A1:A10, B1)" in any cell, the cell should be 55, and the B1 cell's color should be color of index is 55, how do I do it?
what's wrong with my syntax?
Bookmarks