สูตรนับจำนวนช่องสี Count Color Excel

สูตรนับจำนวนช่องสี Count Color Excel. กรณีนี้สำหรับคนที่ต้องการนับจำนวน สีในช่องแต่ละช่อง แต่ละสี ว่าสีนั้น มีจำนวนเท่าไหร่

เริ่มจาก ไปที่ DEVELOPER(ใครยังไม่ได้เปิดไปตั้งค่าใช้งานก่อนนะครับ) :arrow_right: Visual Basic :arrow_right: Insert :arrow_right: Module :arrow_right: วางโค้ตลงไป กดบันทึก

โค้ตที่ใช้

Function ColorFunction(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
ColorFunction = vResult
End Function

จากนั้นใช้สูตร

=ColorFunction(ตัวอย่างสีอ้างอิง,พื้นที่ที่ต้องการให้นับทั้งหมด)

ตัวอย่างการใช้งาน

=ColorFunction(B10,B2:D7)

ต้วอย่าง

2021-07-23_15-24-24

ไฟล์ตัวอย่าง

Eleceasy.com-count_color.xlsx (28.0 KB)