'Can I separate the range in VBA?
Here is the Excel macro to sum the range with same font color.
I'd like to separate the sumRange into range of checking font color and range of getting value for summation. Is it possible?
Function ColorSum(sumRange As Range, colorRange As Range, Optional colorType As Boolean = False) As Double
Application.Volatile (True)
Dim rng As Range, result As Double
If colorType Then
For Each rng In sumRange
If rng.Font.ColorIndex = colorRange.Font.ColorIndex Then result = result + rng.Value
Next rng
Else
For Each rng In sumRange
If rng.Interior.ColorIndex = colorRange.Interior.ColorIndex Then result = result + rng.Value
Next rng
End If
ColorSum = result
End Function
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
