2012-09-11 56 views
0

我知道这是一种查看单元格值是否包含某个字符串的方法。我知道一些编程语言使用%...%。Excel VBA - 单元格值包含'MIG'

If shtVO.Cells(Row, 1).Value <> "%MIG%" Then 
     shtVO.Cells(Row, 1).Value = shtVO.Cells(Row, 1).Value + "MIG" 
    End If 

我想看看我的小区A已经包含了MIG,如果这样做,不应该更新的值,如果它不包含MIG,应该更新MIG电流值。

回答

2

试试这个

If not shtVO.Cells(Row, 1).Value like "*MIG*" Then 
+0

完美!谢谢 :) – CustomX

1
If InStr(0, shtVO.Cells(Row, 1).Value, "MIG", vbTextCompare)=0 Then 
    shtVO.Cells(Row, 1).Value = shtVO.Cells(Row, 1).Value + "MIG" 
End If 
相关问题