I need to apply MATCH function to a range of dates (in VBA. The standard MATCH function written as cell formula does work as intended.) looking for the largest possible index whose corresponding date is <= the looked-up date. Here's my code and a minimum working example:
Function test_debug_func(x As Date, arr As Range) As Integer
Debug.Print "entered function"
test_debug_func = WorksheetFunction.Match(x, arr, 1)
End Function
And I checked that the function is indeed entered by printing the debug statement. However, it cannot proceed with the WorksheetFunction.Match function. I also checked that all dates are indeed Date and not other formats.
It simply doesn't make any sense to me why this wouldn't work. Could anyone kindly help? Thanks!
