0. VBA에서 삽입 > 모듈 후
1.
Function CountBackColor(range_data As Range, criteria As Range) As Long
Dim datax As Range
Dim xcolor As Long
xcolor = criteria.Interior.ColorIndex
For Each datax In range_data
If datax.Interior.ColorIndex = xcolor Then
CountBackColor = CountBackColor + 1
End If
Next datax
End Function
2.
Function CountBackColor2(range_data As Range, criteria As Range) As String
Dim datax As Range
Dim xcolor As Long
Dim arrStr(100) As String
Dim strTemp As String
Dim i As Integer
Dim MD As Integer
i = 0
MD = 0
xcolor = criteria.Interior.ColorIndex
For Each datax In range_data
If datax.Interior.ColorIndex = xcolor Then
If datax.Value <> "진주 출장" Then
If arrStr(i) <> datax.Value Then
If i > 0 Then
arrStr(i) = arrStr(i) + "(" + Str(MD + 1) + ")"
MD = 0
End If
i = i + 1
arrStr(i) = datax.Value
Else
MD = MD + 1
End If
End If
End If
Next datax
arrStr(i) = arrStr(i) + "(" + Str(MD + 1) + ")"
For j = 1 To i
If j = 1 Then
strTemp = arrStr(j)
Else
strTemp = strTemp + "," + arrStr(j)
End If
Next j
strTemp = strTemp + "[" + Str(j - 1) + "]"
CountBackColor2 = strTemp
End Function