‘A列单元格,注意复制操作。另一个单元格里只能有一个今天或明天或昨天。
Sub 加颜色()
Dim m, a, b, c As String
a = "今天"
b = "昨天"
c = "明天"
For i = 1 To [A65536].End(xlUp).Row
m = Cells(i, 1)
If InStr(m, a) > 0 Then
j = InStr(m, a)
With Cells(i, 1).Characters(Start:=j, Length:=2).Font
.Color = &HFF00&
End With
End If
If InStr(m, b) > 0 Then
k = InStr(m, b)
With Cells(i, 1).Characters(Start:=k, Length:=2).Font
.Color = &HFF&
End With
End If
If InStr(m, c) > 0 Then
l = InStr(m, c)
With Cells(i, 1).Characters(Start:=l, Length:=2).Font
.Color = &HFF0000
End With
End If
Next
End Sub
写代码才可以实现