您现在的位置是:首页 > Excel技巧>Excel VBA查找变色

excel查找后变色-Excel VBA查找变色

发布于2022-04-150人已围观

从C1:D10中查找同行第m列中的字符(n为连续字符数),把相同字符变成红色

Sub CGC()

    Dim i As Long

    Dim tmpRange As Range

    Dim strS As String

    For Each tmpRange In Range([c1], [d10])

        strS = tmpRange.Text

        For i = 1 To Len(strS)

            If Cells(tmpRange.Row, m).Text Like "*" & Mid$(strS, i, n) & "*" Then

                With tmpRange.Characters(Start:=i, Length:=1).Font

                    .ColorIndex = 3

                End With

            End If

        Next

    Next

End Sub


相关文章

文章评论

表情

共0条评论
  • 这篇文章还没有收到评论,赶紧来抢沙发吧~

标签云

站长特荐