Steph
It might look something like:
Function fFindValues(ByRef FindValue As Range, _
ByRef LookInValues As Range, _
ByVal ColumnOffset As Integer)
' example call: =fFindValues(A1,B:B,1)
' looks for the value in cell A1 in column B
' example call: =fFindValues(A1,B1:B20,1)
' looks for the value in cell A1 in cells B1:B20
' uses ColumOffset to determine where to get the returned value(s)
Application.Volatile
Application.ScreenUpdating = False
Dim cell As Range
Dim FindValues
FindValues = ""
For Each cell In LookInValues
If cell.Value = FindValue Then
If FindValues = "" Then
FindValues = cell.Offset(0, ColumnOffset).Value
Else
FindValues = FindValues & ", " & _
cell.Offset(0, ColumnOffset).Value
End If
End If
Next
fFindValues = FindValues
Application.ScreenUpdating = True
End Function
It's not tested to death but it works in the simple case. Possibly/probably
not the quickest way to do it. Might prompt improvements and alternatives
though.
Note: it's much quicker if you limit the selection to cells rather than the
column. You could, of course, work out how many cells are in use in the
column and restrict it yourself.
Regards
Trevor