Try this function in a REGULAR module using the formula
=fmv("a","p","f")
where a is the string
p is the column and f is for first or l for last
Option Explicit
Function fmv(mv As String, mc As String, fl As String)
Dim mcl As Long
mcl = Cells(1, mc).Column
If UCase(fl) = "F" Then
fmv = Columns(mcl).Find(What:=mv, LookIn:=xlValues, LookAt:= _
xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False).Address
Else
fmv = Columns(mcl).Find(What:=mv, LookIn:=xlValues, LookAt:= _
xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlPrevious, _
MatchCase:=False).Address
End If
End Function
--
Don Guillett
Microsoft MVP Excel
SalesAid Software
"xp" wrote in message
...
Using XL2007.
I need a reusable "generic" function that I can call and feed it three
variables:
1) a string to find
2) the column to find it in
3) whether to return the cell address of the first occurrence (top) or
last
(bottom)
Can someone please help me out with this?
Thanks!