Find specific letters in a specific range

huorsa

Board Regular
Joined
Feb 15, 2002
Messages
101
What should I do to find specific letters in a specific range and the get the cells that contain the letters I am looking for. Per example: A1 apple
B1 orange
C1 banana

I want to know which cells contain the letter "e" (A1 and B1), get a textbox or something that let me know which cells contain the letter "e".

Hugo
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Use this formula

Code:
Function ContainsText(Rng As Range, Text As String) As String
Dim T As String
Dim Cll As Range
For Each Cll In Rng
    If InStr(Cll.Text, Text) > 0 Then
        If Len(T) = 0 Then
            T = Cll.Address(False, False)
        Else
            T = T & "," & Cll.Address(False, False)
        End If
    End If
Next Cll
ContainsText = T
End Function

In VBA use it like

Code:
MsgBox ContainsText(Range("A1:A3"),"e")

And in Excel, use like

=ContainsText(A1:A3,"e")
 
Upvote 0

Forum statistics

Threads
1,214,622
Messages
6,120,576
Members
448,972
Latest member
Shantanu2024

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