I'm sure this can be done better. Thisdate is a set of dates in, say a1 to a100. in b1 to b100 there are values [the val range]. I'm trying to return the value in val that corresponds to thisdate matching startdate.

this code produces an error.


Function INIT(THISDATE As Range, STARTDATE As Date, VAL As Range)
Dim C, B
Dim ICOUNT As Integer, MAX As Integer
Dim ARR1()
Dim ARR2()
MAX = THISDATE.Count
ReDim ARR1(1 To MAX)
ReDim ARR2(1 To MAX)

ARR1 = Array(THISDATE)
ARR2 = Array(VAL)
For ICOUNT = 1 To MAX
If DateValue(ARR1(ICOUNT)) = STARTDATE Then
INIT = ARR2(ICOUNT)
Exit Function
End If
Next ICOUNT
End Function