r = .Columns(1).Find(what:="*", LookIn:=xlValues, SearchDirection:=xlPrevious).Row
c = color1
CC = 1
.Cells(1, "A").Font.color = c
For i = 1 To r
a = .Cells(i, "A")
If i = 1 Then
b = .Cells(i + 1, "A")
Else
b = .Cells(i - 1, "A")
End If
If a = b Then
.Cells(i, "A").Font.color = c
ElseIf a <> b And CC = 1 Then
c = color2
CC = 0
.Cells(i, "A").Font.color = c
ElseIf a <> b And CC = 0 Then
c = color1
CC = 1
.Cells(i, "A").Font.color = c
End If
Next i
End With
End Sub
複製代碼
作者: 准提部林 時間: 2020-12-21 19:59
Sub TEST()
Dim xR As Range, xH As Range, T$, Cr, c%
[A:A].Font.ColorIndex = 1
Cr = Array(5, 3)
For Each xR In Range([A1], [A65536].End(xlUp))
If xR & "" <> T Then Set xH = xR: T = xR & ""
If xR(2) & "" <> T Then
Range(xH, xR).Font.ColorIndex = Cr(c)
c = (c + 1) Mod 2
End If
Next
End Sub作者: hcm19522 時間: 2020-12-22 09:59
Sub Test1224()
Dim Cor: Cor = Array(10, 5)
Range([A1], [A1].End(4)).Select
On Error Resume Next
Do Until Err <> 0
K% = K% + 1: Selection.Font.ColorIndex = Cor(K Mod 2)
Selection.ColumnDifferences(ActiveCell).Select
Loop: [A1].Activate
End Sub作者: Kubi 時間: 2020-12-25 21:30
回復 1#s13030029
請參考
Sub test()
Dim mycolor%, x$, cell As Range
For Each cell In Range([A1], [A65536].End(3))
If cell.Value <> x Then
mycolor = IIf(mycolor = 5, 10, 5)
x = cell.Value
End If
cell.Font.ColorIndex = mycolor
Next cell
End Sub