Advertisement
Guest User

Untitled

a guest
Feb 6th, 2016
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. Public Function SumByColor(rng As Range, clr As String) As Double
  2. Application.Volatile
  3.  
  4. Dim s As Double
  5. s = 0
  6. Dim r As Range
  7. Dim c As Long
  8. If clr = "red" Then
  9. c = RGB(256, 0, 0)
  10. End If
  11. If clr = "black" Then
  12. c = RGB(0, 0, 0)
  13. End If
  14.  
  15. For Each r In rng
  16. If r.Font.Color = c Then
  17. s = s + r.Value
  18. End If
  19. Next r
  20.  
  21. SumByColor = s
  22. End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement