我知道有比拥有多个InStr()函数更好的方法,但是我对VBA不够满意,无法知道如何实现它们。因此,与此同时,我认为拥有多个InStr()可以工作,但是我似乎无法理清所有InStr()的语法问题。请帮忙!
'Search code
LastRow = Alpha.Cells.Find(What:="*", After:=[A1], SearchOrder:=xlByRows,_
SearchDirection:=xlPrevious).Row
'Loop search code
For i = 2 To LastRow
'Check if columns do not match
If Alpha.Range("G" & i) <> Alpha.Range("H" & i) Then
'Pull out mismatches if contain specific strings
Select Case True
'Search for specific strings
Case ((InStr(1, Alpha.Range("H" & i), "E08.3") > 0) Or _
(InStr(1, Alpha.Range("H" & i), "E08.4") > 0) Or _
(InStr(1, Alpha.Range("H" & i), "E08.5") > 0) Or _
(InStr(1, Alpha.Range("H" & i), "E08.6") > 0) Or _
(InStr(1, Alpha.Range("H" & i), "E08.8") > 0) Or _
(InStr(1, Alpha.Range("H" & i), "E08.9") > 0)) Or _
(InStr(1, Alpha.Range("H" & i), "E09") > 0) Or _
(InStr(1, Alpha.Range("H" & i), "E10") > 0) Or _
(InStr(1, Alpha.Range("H" & i), "E11") > 0) Or _
(InStr(1, Alpha.Range("H" & i), "E13.0") > 0) Or _
(InStr(1, Alpha.Range("H" & i), "E13.1") > 0) Or _
(InStr(1, Alpha.Range("H" & i), "E13.2") > 0) Or _
(InStr(1, Alpha.Range("H" & i), "E13.3") > 0)) And _
((InStr(1, Alpha.Range("K" & i), "J0718") > 0) Or _
(InStr(1, Alpha.Range("K" & i), "J2778") > 0) Or _
(InStr(1, Alpha.Range("K" & i), "J9035") > 0) Or _
(InStr(1, Alpha.Range("K" & i), "J7312") > 0) Or _
(InStr(1, Alpha.Range("K" & i), "C9257") > 0))
'look for UniqueID(colA) in TrackSheet to avoid duplicate copy
DuplicateCheck = Application.Match(Alpha.Range("A" & i).Value,_
TrackSheet.Columns(1), 0)
If IsError(DuplicateCheck) Then
'If no match on UniqueID, copy values
TrackSheet.Cells(Rows.Count, 1).End(xlUp)._
Offset(1,0).EntireRow.Value = Alpha.Rows(i).Value
End If
End Select
End If
Next i