Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 49
Default a formula that return the cell location in a range

Element value is in A4 and the range is A5:E30
B4 is to show the location

Element value may not be unique.
Thanks
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10,124
Default a formula that return the cell location in a range

Homework?

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"danpt" wrote in message
...
Element value is in A4 and the range is A5:E30
B4 is to show the location

Element value may not be unique.
Thanks


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default a formula that return the cell location in a range

Try this small UDF:

Function WhereInTheWorld(rf As Range, r As Range) As String
Dim rr As Range
WhereInTheWorld = "No Luck"
v = rf.Value
For Each rr In r
If rr.Value = v Then
WhereInTheWorld = Replace(rr.Address, "$", "")
Exit Function
End If
Next
End Function


and use in the worksheet like:


=WhereInTheWorld(A4,A5:E40)



--
Gary''s Student - gsnu200851


"danpt" wrote:

Element value is in A4 and the range is A5:E30
B4 is to show the location

Element value may not be unique.
Thanks

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 49
Default a formula that return the cell location in a range

Thank you very much.
It works great.


"Gary''s Student" wrote:

Try this small UDF:

Function WhereInTheWorld(rf As Range, r As Range) As String
Dim rr As Range
WhereInTheWorld = "No Luck"
v = rf.Value
For Each rr In r
If rr.Value = v Then
WhereInTheWorld = Replace(rr.Address, "$", "")
Exit Function
End If
Next
End Function


and use in the worksheet like:


=WhereInTheWorld(A4,A5:E40)



--
Gary''s Student - gsnu200851


"danpt" wrote:

Element value is in A4 and the range is A5:E30
B4 is to show the location

Element value may not be unique.
Thanks

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,934
Default a formula that return the cell location in a range

If the OP was willing to tolerate an error being returned if the search
fails (as opposed to your "No Luck" message), then a one-line UDF will
work...

Function WhereIs(rf As Range, r As Range) As String
WhereIs = r.Find(rf.Value, r(r.Count), , xlWhole, xlByRows).Address(0, 0)
End Function

Of course, if he didn't want the error, it would take a couple of extra
lines...

Function WhereIs(rf As Range, r As Range) As String
WhereIs = "No Luck"
On Error Resume Next
WhereIs = r.Find(rf.Value, r(r.Count), , xlWhole, xlByRows).Address(0, 0)
End Function

--
Rick (MVP - Excel)


"Gary''s Student" wrote in message
...
Try this small UDF:

Function WhereInTheWorld(rf As Range, r As Range) As String
Dim rr As Range
WhereInTheWorld = "No Luck"
v = rf.Value
For Each rr In r
If rr.Value = v Then
WhereInTheWorld = Replace(rr.Address, "$", "")
Exit Function
End If
Next
End Function


and use in the worksheet like:


=WhereInTheWorld(A4,A5:E40)



--
Gary''s Student - gsnu200851


"danpt" wrote:

Element value is in A4 and the range is A5:E30
B4 is to show the location

Element value may not be unique.
Thanks




  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default a formula that return the cell location in a range

Very nice....Thanks
--
Gary''s Student - gsnu200851


"Rick Rothstein" wrote:

If the OP was willing to tolerate an error being returned if the search
fails (as opposed to your "No Luck" message), then a one-line UDF will
work...

Function WhereIs(rf As Range, r As Range) As String
WhereIs = r.Find(rf.Value, r(r.Count), , xlWhole, xlByRows).Address(0, 0)
End Function

Of course, if he didn't want the error, it would take a couple of extra
lines...

Function WhereIs(rf As Range, r As Range) As String
WhereIs = "No Luck"
On Error Resume Next
WhereIs = r.Find(rf.Value, r(r.Count), , xlWhole, xlByRows).Address(0, 0)
End Function

--
Rick (MVP - Excel)


"Gary''s Student" wrote in message
...
Try this small UDF:

Function WhereInTheWorld(rf As Range, r As Range) As String
Dim rr As Range
WhereInTheWorld = "No Luck"
v = rf.Value
For Each rr In r
If rr.Value = v Then
WhereInTheWorld = Replace(rr.Address, "$", "")
Exit Function
End If
Next
End Function


and use in the worksheet like:


=WhereInTheWorld(A4,A5:E40)



--
Gary''s Student - gsnu200851


"danpt" wrote:

Element value is in A4 and the range is A5:E30
B4 is to show the location

Element value may not be unique.
Thanks



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I return the location (as a range) of ActiveCell? Caeres Excel Discussion (Misc queries) 4 October 6th 08 09:44 PM
How do you have a formula range be determined by the location ofanother cell? Daniel[_3_] Excel Worksheet Functions 2 February 8th 08 03:01 PM
How do I return the cell location aneuro Excel Discussion (Misc queries) 4 May 27th 07 01:09 PM
how do I return tthe location (cell) when using the max function Holke Excel Discussion (Misc queries) 6 March 11th 07 01:27 AM
Formula to return ADDRESS of cell in range that meets criteria Christie Excel Worksheet Functions 1 March 4th 05 11:13 PM


All times are GMT +1. The time now is 07:45 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"