Thread: Max date
View Single Post
  #14   Report Post  
Biff
 
Posts: n/a
Default

Hi!

Don't know anything about VBA but when I try this I get a compile syntax
error with this section highlighted:

myarray(Month(cell.Value)) = _
WorksheetFunction.Min(Day(cell.Value),

Biff

wrote in message
...
I have also tried to do this as an array and drawn a blank
however a UDF if it would help

Function MaxDate(myRange As Range) As Integer

Dim myarray(1 To 12) As Integer
For Each cell In myRange
If myarray(Month(cell.Value)) < 0 Then
myarray(Month(cell.Value)) = _
WorksheetFunction.Min(Day(cell.Value),
myarray(Month(cell.Value)))
Else
myarray(Month(cell.Value)) = Day(cell.Value)
End If
Next cell

MaxDate = WorksheetFunction.Max(myarray)

End Function

Feels like brute force though

hth RES