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

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
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,213,557
Messages
6,114,291
Members
448,564
Latest member
ED38

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