Skip to content

Instantly share code, notes, and snippets.

@wizard04wsu
Last active March 22, 2017 16:39
Show Gist options
  • Save wizard04wsu/d1c7b2c3dcdae62b3743 to your computer and use it in GitHub Desktop.
Save wizard04wsu/d1c7b2c3dcdae62b3743 to your computer and use it in GitHub Desktop.
VBA Max and Min functions
Function max(ParamArray ListItems() As Variant)
Dim i As Integer
If UBound(ListItems) >= 0 Then
max = ListItems(0)
For i = 1 To UBound(ListItems)
If ListItems(i) > max Then max = ListItems(i)
Next i
End If
End Function
Function min(ParamArray ListItems() As Variant)
Dim i As Integer
If UBound(ListItems) >= 0 Then
min = ListItems(0)
For i = 1 To UBound(ListItems)
If ListItems(i) < min Then min = ListItems(i)
Next i
End If
End Function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment