Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

small not working

Status
Not open for further replies.

LJ Hamlin

Programmer
Apr 3, 2018
3
US
Any idea why the 3rd and the 4th smallest would work, but not the 2nd?
everything is dimmed

Application.Goto Reference:=Worksheets("Sheet1").Range("X" & LStrt & ":X" & LEnd)
Set bidRng = Selection
bTwo(0) = WorksheetFunction.Aggregate(15, 4, bidRng, 2)
bThree(0) = WorksheetFunction.Aggregate(15, 4, bidRng, 3)
bFour(0) = WorksheetFunction.Aggregate(15, 4, bidRng, 4)
Application.Goto Reference:=Worksheets("AnalysisOutput").Range("A" & SRow)
Selection.Offset(0, 10).Value = bTwo(0)
Selection.Offset(0, 11).Value = bThree(0)
Selection.Offset(0, 12).Value = bFour(0)

How can 3rd and 4th smallest work and not 2nd smallest?
Thanks for your input.
 
I'm going to re-sort the range and take the offset to get the 2nd, 3rd and 4th smallest. It's just weird that the 3rd and 4th work, but not the 2nd.
 
Here's a more compact version...

Code:
'
    Dim bidRng As Range, lStrt As Long, lEnd As Long, sRow As Long
        
    Set bidRng = Worksheets("Sheet1").Range("X" & lStrt & ":X" & lEnd)
        
    With Worksheets("AnalysisOutput").Range("A" & sRow)
        .Offset(0, 10).Value = WorksheetFunction.Aggregate(15, 4, bidRng, 2)
        .Offset(0, 11).Value = WorksheetFunction.Aggregate(15, 4, bidRng, 3)
        .Offset(0, 12).Value = WorksheetFunction.Aggregate(15, 4, bidRng, 4)
    End With

Skip,

[glasses]Just traded in my OLD subtlety...
for a NUance![tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top