Tutorial How Count Fill Color With VBA Excel

in #elvi7 years ago (edited)

Hi, I'm is a new bie in Steemit, please help me and vote me. Thanks

Tutorial how count fill color with VBA Excel

  1. Open Excel
  2. Make some fill color in cell
    ex1.JPG
  3. Enable macro setting on Excel option
    macro.JPG
  4. Create Module VBA Project, Press ALT+F11
    new vba.JPG
  5. 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
    kode.JPG
  6. Save as file as type macro excel
    sav.JPG
  7. Enter the following formula :
    =Xcolor(criteria; range)
    rum.JPG
  8. Copy and Paste Formula to other color
    end.JPG
  9. End.
Sort:  

Welcome to Steemit! Enjoy the ride as much as you can!

Thank you, I hope always gets support from visitors