Access/VBA Library


Returns the smallest value in a set of values.


Min( args-1 [, args-2 [,...[, args-N]]] )
Name Type Description
args Variant Required. Values for which you want to determine the smallest value. Arguments of type Object are ignored.
Return value

Variant : The smallest value of the given set of values.

Public Function Min(ParamArray args())
    Dim MinValue
    Dim Index As Long
    MinValue = Empty
    For Index = LBound(args) To UBound(args)
        If Not IsMissing(args(Index)) Then
            If Not IsObject(args(Index)) Then
                If args(Index) < MinValue Or MinValue = Empty Then MinValue = args(Index)
            End If
        End If
    Next Index
    Min = MinValue
End Function


  • It's wise to make sure the arguments are of the same type.
  ' Comparing numeric values
  MsgBox Min(1, 4, 6.1, 5, -3, 4, 6)
  ' Will result in : -3
  ' Comparing strings
  Msgbox Min("ABC", "Just a string", "Whatever", "what's new?")
  ' Will result in : ABC
  ' Comparing dates
  MsgBox Min(Date, Now(), DateAdd("m", 1, Date))
  ' Will result in the value of the @Date funtion