简体   繁体   中英

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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