Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Find Most recent date in array containing dates

Status
Not open for further replies.

PeasNCarrots

Programmer
Jun 22, 2004
73
US
Here is my code..


Sub TestArray()


Dim test(2)
test(0) = CDate(#4/2/2004#)
test(1) = CDate(#3/3/2005#)
test(2) = CDate(#3/5/2002#)


MsgBox FindMax(test)

End Sub


Function FindMax(A() As Variant) As Variant

Dim Start As Integer, Finish As Integer, i As Integer

Dim max As Variant

Start = LBound(A)
Finsish = UBound(A)
max = A(Start)

For i = Start To Finish
If A(i) > max Then max = A(i)
Next

FindMax = max


End Function
 
Replace this:
Finsish = UBound(A)
By this:
Finish = UBound(A)
And I suggest to add the Option Explicit instruction at top of the Declarations section ...

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
I can't belive I did not notice that. Must becoming blind.

Thanks. Santa will be very nice to you this year.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top