VBA Excel
I keep getting an Error 2042 returned by the match function here. I have carfully set my Range variables to the correct columns and rows. The range objects are all dates. It seems no matter what I do I get that error. Any ideas? Here is the code:
Code:Sub test() Dim matchstart As Range Dim matchend As Range Dim matchRange As Range c = CDate("1/28/2004") Set matchstart = Workbooks("datafile.xls").Sheets("futexpiry").Cells(2, 5) Set matchend = Workbooks("datafile.xls").Sheets("futexpiry").Cells(500, 5) Set matchRange = Workbooks("datafile.xls").Sheets("futexpiry").Range(matchstart, matchend) FirstMatch = Application.Match(c, matchRange, 1) End Sub




Reply With Quote