当我的长度超过 5 个字符时,如何将颜色变成绿色。我一直收到“对象不支持此属性”错误
Sub deme()
Dim lastrow As Long
Dim a As Integer
a = 1
Dim cc As String
Dim i As Long
lastrow = Worksheets("sheet1").Range("C1").End(xlDown).Row - 1
For i = a To lastrow
cc = Worksheets("sheet1").Range("C" & i)
If Len(cc) > 5 Then
Worksheets("sheet1").Character(cc, i).Font.Color = vbRed
End If
Next i
End Sub
答案1
代替
Worksheets("sheet1").Character(cc, i).Font.Color = vbRed
我把它改成了
Worksheets("sheet1").Range("C" & i).Font.Color = vbRed