我正在尝试格式化仅小写字母为红色,所有其他大写字母以及所有数字为黑色的单元格。
单元格是公式的结果,引用另一页。所引用的单元格由该页面内的其他公式组成。
如何使字体的格式与公式一起使用(在这种情况下,将小写字母涂成红色很容易,因为我一路上将它们提取到了自己的单元格中),或者您对有条件的建议格式或代码仅将小写字母变成红色?
答案 0 :(得分:0)
"... OR do you have suggestion for ... code to made only lower case letters red"
是的,就是这样,但是效率并不高
Option Explicit
Sub LowercaseToRed()
SpeedUp True
On Error GoTo ErrClose
Dim cell As Range
For Each cell In Range("A1:D10")
Dim i As Long
For i = 1 To cell.Characters.count
If 97 <= Asc(Mid(cell.Value2, i, 1)) And Asc(Mid(cell.Value2, i, 1)) <= 122 Then
cell.Characters(i, 1).Font.color = vbRed
End If
Next i
Next cell
ErrClose:
SpeedUp False
End Sub
Sub SpeedUp(ByVal toggleOn As Boolean)
With Application
.Calculation = IIf(toggleOn, xlCalculationManual, xlCalculationAutomatic)
.ScreenUpdating = Not toggleOn
.DisplayStatusBar = Not toggleOn
.EnableEvents = Not toggleOn
End With
End Sub