ExcelVBA中怎样得到当前使用的填充颜色值

如题所述

第1个回答  2017-05-13
Sub s()
c = Array(33, 14, 47, 6, 7, 12)
n = Cells(Rows.Count, 11).End(3).Row
k = 0
Do While n > 1 And k < 20
cc = 0
For i = 11 To 52 Step 14
f1 = False
f2 = False
For j = 0 To 6
If Cells(n, i + j) = Cells(n - 1, i + j) Then f1 = True: Exit For
Next
For j = 7 To 13
If Cells(n, i + j) = Cells(n - 1, i + j) Then f2 = True: Exit For
Next
If f1 And f2 Then
For j = 0 To 13
If Cells(n, i + j) = Cells(n - 1, i + j) Then
Cells(n, i + j).Interior.ColorIndex = c(cc)
End If
Next
ElseIf f1 Then
For j = 0 To 6
If Cells(n, i + j) = Cells(n - 1, i + j) Then
Cells(n, i + j).Interior.ColorIndex = c(cc + 1)
End If
Next
ElseIf f2 Then
For j = 7 To 13
If Cells(n, i + j) = Cells(n - 1, i + j) Then
Cells(n, i + j).Interior.ColorIndex = c(cc + 1)
End If
Next
End If
cc = cc + 2
Next
n = n - 1
k = k + 1
Loop
End Sub本回答被网友采纳
相似回答
大家正在搜