我有一个宏来为其中包含单词 VOID 的单元格着色。
我在这样的单元格中也有 VOID 这个词:[$189.00VOID]。
我找不到为所有包含以下内容的单元格着色的方法:
无效和 [$189.00无效]
或其中的任何其他美元金额。
Sub Macro1()
On Error Resume Next
Dim current As String
For i = 1 To 65536 ' go from first cell to last
current = "c" & i ' cell counter
Range(current).Select ' visit the current cell
If Range(current).Text = "VOID" Then ' if it says VOID then we...
With Selection.Interior
.ColorIndex = 3 ' ...go red
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
End With
End If
If Range(current).Text = "FORWARDED" Then ' if it says FORWARDED then we...
With Selection.Interior
.ColorIndex = 4 ' ...go green
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
End With
End If
Next i ' loop and check the next cell
End Sub