Find text within a table

b0unce

Board Regular
Joined
Apr 22, 2009
Messages
75
Hello,

I am trying to write a formula, which gave me the address of a cell which contains specific text. Example:

ABCD
1Text to findResult
2ApplesC6
3
4
5GrapesBananasPineapplesPotatoes
6PearsCarrotsApplesStrawberries
7PeasCucumbersPassionfruitsTomatoes

<tbody>
</tbody>

In cell C2 I need to type in a formula, which searched the table A5:D7 for a text string which is in B2 and displayed the resulting cell address. Have tried multiple options but nothing seems to work.
Does anyone have any ideas how to achieve the wanted result?
Thank you in advance!
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Here's a UDF you can use until someone provides you with the proper combination of native worksheet functions to solve your problem. An example of use of the UDF is below, followed by instructions for installing the UDF and the UDF itself.
Excel Workbook
ABCD
1Text to findResult
2ApplesC6
3
4
5GrapesBananasPineapplesPotatoes
6PearsCarrotsApplesStrawberries
7PeasCucumbersPassionfruitsTomatoes
Decade



To install the UDF:
1. With your workbook active press Alt and F11 keys. This will open the VBE window.
2. In the project tree on the left of the VBE window, find your project and click on it.
3. On the VBE menu: Insert>Module
4. Copy the UDF from your browser window and paste it into the white space in the VBE window.
5. Close the VBE window and Save the workbook. If you are using Excel 2007 or a later version do a SaveAs and save it as a macro-enabled workbook (.xlsm file extension).
6. Use the UDF as you would any native Excel function.
7. Make sure you have enabled macros whenever you open the file or the code will not run.
Code:
Function FoundTextAddress(R As Range, Txt As String) As String
Dim Fnd As Range
Set Fnd = R.Find(Txt, lookat:=xlWhole)
If Fnd Is Nothing Then
    FoundTextAddress = ""
Else
    FoundTextAddress = Fnd.Address(0, 0)
End If
End Function
 
Upvote 0
With a formula... Control+shift+enter, not just enter:

=IF(COUNTIFS(A5:D7,B2)=1,ADDRESS(MIN(IF(A5:D7=B2,ROW(A5:D7))),MIN(IF(A5:D7=B2,COLUMN(A5:D7))),4),"")
 
Upvote 0

Forum statistics

Threads
1,215,660
Messages
6,126,082
Members
449,286
Latest member
Lantern

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