- 帖子
- 97
- 主題
- 33
- 精華
- 0
- 積分
- 129
- 點名
- 0
- 作業系統
- Win 7
- 軟體版本
- office 2007
- 閱讀權限
- 20
- 性別
- 男
- 註冊時間
- 2019-5-7
- 最後登錄
- 2022-8-25
|
這是我目前想到的方法,如有高手有更好的方式歡迎指教~~~- Sub color()
- color1 = -3902908
- color2 = -13270700
- With ActiveSheet
- 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
複製代碼 |
|