Sub 万位以下变为灰色()
Dim i, q, l, k As Long
Dim p As String
For q = 1 To Cells(1, Columns.Count).End(xlToLeft).Column
For i = 1 To Cells(Rows.Count, q).End(xlUp).Row
Cells(i, q).Select
With ActiveCell.Characters.Font
.ColorIndex = 1
End With
If IsNumeric(Cells(i, q).Value) Then
Selection.NumberFormatLocal = "@"
If Cells(i, q).Value > 10000 Then
p = Cells(i, q).Value
If InStr(p, ".") = 0 Then
p = p & ".00"
Cells(i, q).Value = p
End If
l = InStrRev(p, ".")
k = Len(p)
With ActiveCell.Characters(Start:=l - 4, Length:=k - l + 5).Font
.ColorIndex = 16
End With
Else
With ActiveCell.Characters(Start:=1, Length:=k).Font
.ColorIndex = 16
End With
End If
End If
Next
Next
End Sub
追问在单元格里的内容原本是数字的情况下如何自动转成文本后执行上述代码呢?我用你这个执行后不行,只有手动去把每个数字都转成文本后执行了才有效