0
我有兩個問題。這需要一些方向。通配符匹配框
1)如何在VBA中使用LIKE運算符時使用Matchcase。下面的代碼只匹配單詞的確切形式。我想我將不得不使用.MatchWildcards = False
,但不知道如何/在哪裏使用它。 例如:搜索'Texas',但這不考慮'texas'。
2)我只需要找到'德克薩斯'這個詞,而不是'TexasRangers'。有沒有辦法做到這一點,我該如何修改我的代碼。
Sub Example()
Dim wsh As Worksheet, i As Long, lngEndRowInv As Long
Set wsh = ActiveSheet
i = 2
Lastr= wsh.Range("A" & wsh.Rows.Count).End(xlUp).Row
While i <= Lastr
If (Cells(i, "F") Like "*New Orleans*") And (Cells(i, "D") Like "*Belfast*") Then
Cells(i, "C").Value = "Deleted"
Cells(i, "C").Font.Color = vbRed
ElseIf Not ((Cells(i, "A") Like "*Texas*") Or (Cells(i, "A") Like "*NY*")) Then
Cells(i, "A").Value = "Not Deleted"
End If
i = i + 1
Wend
End Sub
感謝@alex K.你能告訴我如何在這段代碼中實現第二點。我有四個搜索執行,你可以在我的上面的代碼中看到。 P.S我仍然在學習這些新概念。謝謝你的時間。 – User124726 2012-02-15 15:45:55
使用第二部分的正則表達式有什麼問題? – 2012-02-15 16:03:29