![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: Feb 2002
Posts: 97
|
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 |
|
|
|
|
|
#2 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Bogota, Colombia
Posts: 11,927
|
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
Code:
MsgBox ContainsText(Range("A1:A3"),"e")
=ContainsText(A1:A3,"e") |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|