几年前我拼凑了这个,现在我需要稍微调整一下,但我对 VBA 很生疏,所以可以参考一些建议:
Sub Colour_Cells_By_Criteria()
Dim myRange As Range
Dim myPattern As String
Dim myLen As Integer
Dim myCell As Range
Set myRange = Range("A1:A1000")
myPattern = "*1*"
myLen = 4
Application.ScreenUpdating = False
Application.StatusBar = "Macro running, please wait...."
For Each myCell In myRange
With myCell
If (.Value Like myPattern) And (Len(.Value) = myLen) Then
myCell.Interior.Color = 65535
myCell.Font.Bold = True
End If
End With
Next
Application.ScreenUpdating = True
Application.StatusBar = False
End Sub
我不想将逻辑捕获的任何单元格着色和加粗,而是将“匹配”一词放在 B 列的同一行中。
任何朝着正确方向的推动都将不胜感激。