Strangely such a function is not available in VBA. Here is one that works with any number of strings or numbers. Function Largest(ParamArray a() As Variant) As Variant 'returns the largest element of list 'List is supposed to be consistent: all nummbers, dates, strings. 'Nulls are allowed, but not in first position. Eventually provide a first low dummy value 'e.g: largest(2,6,-9,7,3) -> 7 ' largest("d", "z", "c", "x") -> "z" 'by Patrick Honorez --- www.idevlop.com Dim result As Variant Dim i As Integer result = a(LBound(a)) For i = LBound(a) + 1 To UBound(a) If result < Nz(a(i), result) Then result = a(i) End If Next i Largest = result End Function
Le blog de iDevlop Luxembourg: infos et astuces sur Office, SQL Server et autres