我目前正在尝试做的是找到并突出显示同时包含某个短语的单元格和(在其他文本中)一个等于或大于20的数字(包括带小数的数字,如25.8332)。我尝试使用FormatConditions,但我无法让它考虑两个同时的条件(一个短语和一个数字)。所以我决定使用If和InStr的组合,但我想知道如何填写等于或大于20 的数字?
答案 0 :(得分:1)
选择您要处理并运行的单元格:
Sub ColorMeYellow()
Dim r As Range, s As String, n As Double
Dim happy As String, CH As String, temp As String
Dim L As Long, i As Long
happy = "happy"
For Each r In Selection
s = r.Value
If InStr(1, s, happy) > 0 Then
L = Len(s)
temp = ""
For i = 1 To L
CH = Mid(s, i, 1)
If CH Like "[0-9]" Or CH = "." Then
temp = temp & CH
End If
Next i
If IsNumeric(temp) Then
If CDbl(temp) > 20 Then
r.Interior.ColorIndex = 6
End If
End If
End If
Next r
End Sub