Help with UDF to find address location and aditional value

rjh

New Member
Joined
Jun 18, 2010
Messages
29
Hi Guys, I am having problems figuring out how to use a UDF that I found on another site. it was written by Allen Wyatt.

Code:
Function GetAddr(rng As Range) As String
    Dim dMin As Double
    Dim lIndex As Long
    Dim sAddress As String

    With Application.WorksheetFunction
        dMin = .Min(rng)
        lIndex = .Match(dMin, rng, 0)
    End With
    GetAddr = rng.Cells(lIndex).Address
End Function


when I put the formula "=getAddr(AI52:AI112)" in the cell
it returns the correct cell location "$AI$52"

I have 2 issues
1) How do I make the formula use a value form 2 different cells like "=("AI" & AN7 & ":" & "AI" & AN8)"

so that the range is a variable.

2) I actually want the UDF to return the value that is in the example above in cell AJ52

a example of my data is:
280.3 29
280.3 29
280.3 18
280.1 19
280.2 29
280.4 13
280.4 13

I want it to return the "19" in the 4th row.

Thanks
Rick
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Code:
Function GetV(col$, fr As Range, lr As Range) As String
Dim lIndex As Long
Dim rng As Range
Set rng = Range(col & fr & ":" & col & lr)
With Application.WorksheetFunction
    lIndex = .Match(.Min(rng), rng, 0)
End With
GetV = rng(lIndex, 2)
End Function
Enter in the worksheet : =GetV("AI",AN7,AN8)
 
  • Like
Reactions: rjh
Upvote 0

Forum statistics

Threads
1,221,443
Messages
6,159,907
Members
451,601
Latest member
terrynelson55

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top