vba select a cell that contains certain text

gtd526

Well-known Member
Joined
Jul 30, 2013
Messages
684
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

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
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,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

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