繁体   English   中英

Excel VBA-单元格值包含“ MIG”

[英]Excel VBA - Cell value contains '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更新当前值。

尝试这个

If not shtVO.Cells(Row, 1).Value like "*MIG*" Then
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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM