Dim colorvalue(100) As Integer
Dim colorcount(100) As Integer
Dim colorindex As Integer
Dim irow As Long
Dim icol As Long
Dim tmpcolor As Integer
Dim tmpret As Integer
Dim i As Long
colorindex = 0
MAXCOLBLANK = 0
MAXROWBLANK = 0
For irow = 1 To 65536 Step 1
MAXCOLBLANK = 0
For icol = 1 To 65536 Step 1
If Cells(irow, icol) = "" Then
MAXCOLBLANK = MAXCOLBLANK + 1
If MAXCOLBLANK > 10 Then
MAXROWBLANK = MAXROWBLANK + 1
Exit For
End If
Else
If Cells(irow, icol) = "颜色计算列表:" Then Exit For
MAXCOLBLANK = 0
MAXROWBLANK = 0
tmpcolor = Cells(irow, icol).Interior.colorindex
tmpret = GetColorIndex(tmpcolor, colorvalue, colorindex)
If tmpret = -1 Then
colorindex = colorindex + 1
colorvalue(colorindex) = tmpcolor
colorcount(colorindex) = 1
Else
colorcount(tmpret) = colorcount(tmpret) + 1
End If
End If
Next
If MAXROWBLANK > 10 Then
Exit For
End If
If Cells(irow, icol) = "颜色计算列表:" Then Exit For
Next
Cells(irow, 1) = "颜色计算列表:"
For i = irow + 1 To irow + 100 Step 1
Cells(i, 1).Interior.colorindex = xlNone
Cells(i, 2) = ""
Next
For i = 1 To colorindex
Cells(irow + i, 1).Interior.colorindex = colorvalue(i)
Cells(irow + i, 2) = colorcount(i)
Next
End Sub
Function GetColorIndex(tmpcolor As Integer, colorvalue() As Integer, colorindex As Integer)
Dim i As Integer
GetColorIndex = -1
For i = 1 To colorindex Step 1
If tmpcolor = colorvalue(i) Then
GetColorIndex = i
Exit For
End If
Next