jalea148
New member
- Joined
- Jul 16, 2012
- Messages
- 23
- Reaction score
- 0
- Points
- 0
Here's my code. I suspect this can be done better without converting to an array.
Immediate window:
1 149 12/4/2012
[2nd debug.print doesn't print anything]
Code:
Function Retval(RangeDates As Range, RangeValues As Range, Testdate)
Dim ARR_RD() As Integer, ARR_RV() As Integer
Dim Lb As Integer, Ub As Integer, I As Integer
Retval = 0
ARR_RD = RangeDates.Value
ARR_RV = RangeValues.Value
Ub = UBound(ARR_RD)
Lb = LBound(ARR_RD)
Retval = 0
Debug.Print Lb, Ub, Testdate
Debug.Print ARR_RD(1).Value, ARR_RD(2), ARR_RD(3), ARR_RD(4)
For I = Lb + 1 To Ub
If Testdate >= ARR_RD(I - 1) And Testdate < ARR_RD(I) Then
Retval = ARR_RV(I - 1)
Exit For
End If
Next I
End Function
Immediate window:
1 149 12/4/2012
[2nd debug.print doesn't print anything]
Last edited by a moderator: