VBA Program algorithm flowchart

 

Function Min(ParamArray Values())
     ' Return the smallest value passed to this function
     ' Min("a","b","c") returns "a"
     ' Min(-10, -100) returns -100
     ' Example of Do While .. Loop

     ' Let i be the first index

     i = LBound(Values, 1)

     Min = Values(i) ' Store the first value

     ' Compare all values to Min except the first one
     Do While i < UBound(Values, 1)
          i = i + 1
          If Min > Values(i) Then Min = Values(i)
     Loop
End Function



Function Max(ParamArray Values())
     ' Return the largest value passed to this function
     ' Max("a","b","c") returns "c"
     ' Max(-10, -100) returns -10
     ' Example of Do .. Loop Until


     Max = Values(UBound(Values, 1)) ' Store the last value
    
     ' Compare all values to Max
     ' starting with the first value

     i = LBound(Values, 1)
    
     Do
          If Max < Values(i) Then Max = Values(i)
          i = i + 1
     Loop Until i >= UBound(Values, 1)  ' Can quit without comparing the last value
End Function