If a UDF is what you want,
Function J(ByVal rSrch As Range) As Variant
Dim rFrm As Range
Dim rInt As Range
Dim rUp As Range
Dim rDn As Range
Set rSrch = Intersect(rSrch, rSrch.Worksheet.UsedRange)
Set rFrm = Application.Caller
Set rInt = Intersect(rFrm.EntireRow, rSrch.EntireColumn)
If LCase(rInt.Value2) = "null" Then
J = "--"
Else
Set rUp = rSrch.Find(What:="Null", _
After:=rInt, _
LookIn:=xlValues, _
LookAt:=xlWhole, _
MatchCase:=False, _
SearchDirection:=xlPrevious)
If rUp Is Nothing Then Set rUp = rSrch(1)
If rUp.Row > rInt.Row Then Set rUp = rSrch(1)
Set rDn = rSrch.Find(What:="Null", _
After:=rInt, _
SearchDirection:=xlNext)
If rDn Is Nothing Then Set rDn = rSrch(rSrch.Cells.Count)
If rDn.Row < rInt.Row Then Set rDn = rSrch(rSrch.Cells.Count)
J = WorksheetFunction.Min(Range(rUp, rDn))
End If
End Function
Bookmarks