Calculating Earliest and Latest Dates:   Return to List

' CODE BELOW cycles through a multidimensional array and
locates earliest and latest dates found in elements 6 & 8 of the array


Dim dtEarliest As Date
Dim dtNew As Date
Dim dtLatest As Date
' ****************************
dtEarliest = aryProdRecords(6, 1)
dtLatest = aryProdRecords(8, 1)
' ****************************
For i = 1 To UBound(aryProdRecords(), 2)
    If Len(aryProdRecords(6, i)) > 0 Then
        dtNew = aryProdRecords(6, i)
        If dtNew < dtEarliest Then
            dtEarliest = dtNew
        End If
    End If
    If Len(aryProdRecords(8, i)) > 0 Then
        dtNew = aryProdRecords(8, i)
        If dtNew > dtLatest Then
            dtLatest = dtNew
        End If
    End If
Next



Note to Webmaster