vba select a cell that contains certain text

gtd526

Well-known Member
Joined
Jul 30, 2013
Messages
696
Office Version
  1. 2019
Platform
  1. Windows
Hello,
I'm using the following VBA code to identify "?" in a certain cell, which is working.
I'd rather just select that identified cell (containing "?") rather that add the text to Column "D".
There will only be a single cell containing "?".
thank you

VBA Code:
Sub Test()
   
    Dim i As Integer

    For i = 1 To 10
        If InStr(1, LCase(Range("B" & i)), "?") <> 0 Then
        Result = "Contains ?????"
        Else
        Result = "Does Not Contain ?????"
        End If

    Range("D" & i) = Result
    Next i
    
End Sub



NBA.xlsm
ABCD
1RankCriteria2Criteria2 PercentageDoes Not Contain ?????
21Rank2, AL & AM >60%75.7%Does Not Contain ?????
315Q>=60%, S>=654.3%Does Not Contain ?????
437K,L,Q,R>0,X,AC36.6%Does Not Contain ?????
5#VALUE!??????????????????Contains ?????
6#VALUE!Your ChoiceDoes Not Contain ?????
7#VALUE!Your ChoiceDoes Not Contain ?????
8Does Not Contain ?????
9Does Not Contain ?????
10Does Not Contain ?????
Sheet1
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Hi
I'm not sure if this is what you want.
just try it
VBA Code:
Sub Test()
   
    Dim i As Integer

    For i = 1 To 10
        If InStr(1, LCase(Range("B" & i)), "?") <> 0 Then
        Range("B" & i).Activate
        End If
    Next i
End Sub
 
Upvote 0
Or just use a tilde to make a wildcard character a regular character.
Code:
Sub Maybe()
    Sheets("Sheet1").Columns(2).Find("~?").Select
End Sub
 
Upvote 0
Solution
Hi
I'm not sure if this is what you want.
just try it
VBA Code:
Sub Test()
  
    Dim i As Integer

    For i = 1 To 10
        If InStr(1, LCase(Range("B" & i)), "?") <> 0 Then
        Range("B" & i).Activate
        End If
    Next i
End Sub
Yes, works fine.
Thank you.
 
Upvote 0

Forum statistics

Threads
1,224,827
Messages
6,181,197
Members
453,021
Latest member
pingpong7117

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top