Tutorial How Count Fill Color With VBA Excel
Hi, I'm is a new bie in Steemit, please help me and vote me. Thanks
Tutorial how count fill color with VBA Excel
- Open Excel
- Make some fill color in cell
- Enable macro setting on Excel option
- Create Module VBA Project, Press ALT+F11
- The following code :
Function Xcolor(rColor As Range, rRange As Range, Optional SUM As Boolean)
Dim rCell As Range
Dim lCol As Long
Dim vResult
lCol = rColor.Interior.ColorIndex
If SUM = True Then
For Each rCell In rRange
If rCell.Interior.ColorIndex = lCol Then
vResult = WorksheetFunction.SUM(rCell, vResult)
End If
Next rCell
Else
For Each rCell In rRange
If rCell.Interior.ColorIndex = lCol Then
vResult = 1 + vResult
End If
Next rCell
End If
Xcolor = vResult
End Function
- Save as file as type macro excel
- Enter the following formula :
=Xcolor(criteria; range)
- Copy and Paste Formula to other color
- End.
Welcome to Steemit! Enjoy the ride as much as you can!
Thank you, I hope always gets support from visitors