Excel String包含string而不是stringequalsstring

你好,我的代码目前看起来像这样

Sub Solbjerg() Set i = Sheets("Samlet") Set e = Sheets("ABC") Dim d Dim j d = 7 j = 7 Do Until IsEmpty(i.Range("A" & j)) If i.Range("A" & j) = "Cinema ABC" Then d = d + 1 e.Rows(d).Value = i.Rows(j).Value End If j = j + 1 Loop End Sub 

然而有时我得到的数据并不总是“电影ABC”,而只是“ABC”。 所以我需要我的代码来search数据是否包含“ABC”而不是“Cinema ABC”。 你们能帮我吗?

更改

 If i.Range("A" & j) = "Cinema ABC" Then 

 If InStr(1, i.Range("A" & j), "ABC") Then 
 Sub Solbjerg() Set i = Sheets("Samlet") Set e = Sheets("ABC") Dim d Dim j d = 7 j = 7 Do Until IsEmpty(i.Range("A" & j)) If i.Range("A" & j) like "*ABC" Then d = d + 1 e.Rows(d).Value = i.Rows(j).Value End If j = j + 1 Loop End Sub 

喜欢,*作为通配符