Results 1 to 3 of 3

Thread: Fix Array

  1. #1
    Join Date
    Mar 2005

    Exclamation Unanswered: Fix Array

    This code was posted on another site by Allan Browne, it works fine for returning the lowest value

    Function Lowest(ParamArray varValues()) As Variant
    Dim i As Integer 'Loop controller.
    Dim varMin As Variant 'Smallest value found so far.

    varMin = Null 'Initialize to null

    For i = LBound(varValues) To UBound(varValues)
    If IsNumeric(varValues(i)) And varValues(i) > 0 Then
    If varMin <= varValues(i) Then
    'do nothing
    varMin = varValues(i)
    End If
    End If

    Lowest = varMin
    End Function

    However, my boss now wants to return the lowest three values. Can someone suggest a way for returning all values that are numeric and greater than 0, rather than just the lowest value

  2. #2
    Join Date
    Nov 2007
    Adelaide, South Australia
    I know of no way to have one function return 3 separate values..... without making it a string... but I also can't think of any reason why you would want to.

    My instinct tells me you should put the values into a table and then use TOP 3 in some SQL on that table.

    What are the 3 values for??
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!

    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

  3. #3
    Join Date
    Nov 2004
    out on a limb
    Provided Answers: 59
    agree its nasty, sounds lke a spreadsheet kludge workaround

    however you coudl return the three lowest values, separated by some suitable character and then use the split function to separate those values... nasty nasty nasty but it will do the job
    I'd rather be riding on the Tiger 800 or the Norton

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts