Welcome to the forum olives (thanks for following me here).
Install this UDF (user defined function) in a module...
Then put this formula in A2 and copy it down for as many rows as you want...Code:Function Smallest(Number As Long) As Variant Dim X As Long, Index As Long, TestValue As Variant, Source As Variant, Results As Variant Source = Range("B1:C" & Cells(Rows.Count, "B").End(xlUp).Row) ReDim Results(1 To UBound(Source), 1 To 1) TestValue = Range("A1").Value For X = 1 To UBound(Source) If Source(X, 1) < TestValue Then Index = Index + 1 Results(Index, 1) = Source(X, 2) End If Next Smallest = WorksheetFunction.Small(Results, Number) End Function
=Smallest(ROW(A1))
HOW TO INSTALL UDFs
------------------------------------
If you are new to UDFs, they are easy to install and use. To install it, simply press ALT+F11 to go into the VB editor and, once there, click Insert/Module on its menu bar, then copy/paste the above code into the code window that just opened up. That's it.... you are done. You can now use Smallest just like it was a built-in Excel function (as show in the example formula above).




Reply With Quote
Bookmarks