简体   繁体   English

找一个实际的? 在 excel vba 中

[英]Find an actual ? in excel vba

I need to find an actual ?我需要找到一个实际的? in a range of cells.在一系列单元格中。 I am using this code:我正在使用此代码:

    Dim rCell As Range
    Dim rArea As Range

' set range variable = Column in the active sheet.
    Set rCell = Range("g1")
    Set rArea = Range("g2:g" & countusers)
    For Each rCell In rArea
    With rCell
    Dim Qmark As Integer
        If InStr(1, (rCell.Value), "~?") > 0 Then
       MsgBox "Cell " & rCell.Address & "has a question mark in it"
        Qmark = Qmark + 1
        End If

I put the ~ in front of the question mark but it's not working.我把 ~ 放在问号前面,但它不起作用。 thanks in advance提前致谢

I figured it out.我想到了。 i added:我补充说:

Dim SearchChar as String
SearchChar = "?"

then replaced "~?"然后替换“~?” in the InStr line with SearchChar and it worked在带有 SearchChar 的 InStr 行中,它起作用了

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

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