几年前,我凑齐了这个东西,现在我需要对其进行一些微调,但是我对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列的同一行中。

任何朝着正确方向前进的人都会受到赞赏。

最佳答案

myCell.Offset(0,1).Value="Match"

关于excel - 使用VBA搜索字符串(模糊逻辑),我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/18856737/

10-10 02:58