View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.misc
Hugh Hugh is offline
external usenet poster
 
Posts: 38
Default Find data in Range, Return Cell Reference

Hi Gary and thanks for the reply. I have no prior experience of UDFs, but
Google has helped me out there.
I've tried the UDF and it works, brilliantly. But I have to save the
workbook as "macro enabled", which our network at work doesn't like. Can
this be avoided?
Thanks again.

"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(A1,B1:D15)

--
Gary''s Student - gsnu200846


"Hugh" wrote:

I want to see if a value in A1 is present in an array, say B1:D15, and then
return the refernce of the cell in which the value is held. The value in A1
will not occur more than once in the array.

For instance, if the value in A1=30, and 30 appears in cell D4, I want to
return D4 (or $D$4).

Is there a formula or function that will return the cell reference of cell
containing a specific value?

Thanks in advance.