方法如下:
1.统计A1:D10中无填充颜色的单元格个数:
2.Alt+F11,输入如下代码:
3.F5执行代码,结果如下:
Sub s()
c = Array(3, 14, 33, 47, 5)
For i = 11 To 353
t = 0
For j = 3 To 11
If Cells(j, i).Interior.ColorIndex = xlNone Then
t = t + 1
Else
Exit For
End If
Next
Cells(1, i) = t
Next
[k1:mo1].Interior.ColorIndex = xlNone
For i = 0 To 4
t = 0
For j = 11 To 353
If Cells(1, j).Interior.ColorIndex = xlNone And Cells(1, j) > t Then
t = Cells(1, j)
End If
Next
For j = 11 To 353
If Cells(1, j) = t Then
Cells(1, j).Interior.ColorIndex = c(i)
End If
Next
Next
End Sub