几年前我拼凑了这个,现在我需要稍微调整一下,但我对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
我不想对逻辑捕获的任何单元格进行着色和粗体处理,而是将“MATCH”一词放在B列的同一行中。
任何正确方向的推动都将受到赞赏。
答案 0 :(得分:3)
myCell.Offset(0,1).Value="Match"