January 7th, 2007, 2:55 am
1. Is the Dates() array dimensioned as a date? Is the Lookup column 33 (AG) a list of dates as well? If so, Excel will use the Long Integer representation. Coercing the lookup value to long worked for me...x = Application.VLookup(CLng(Dates(i)), Worksheets("XMKT").Range(Cells(8, 33), Cells(1007, 35)), 3)2. Your code will likely fail if the active sheet is not "XMKT" because the Cells(x,y) references are not fully qualified. Do something like the following to make it more robust...'''''''''''''''''''''''''''''''''''''''Sub test()Dim x, i, Dates(1 To 1) As DateDim TestRng As RangeWith ThisWorkbook With .Worksheets("XMKT") Set TestRng = .Range(.Cells(8, 33), .Cells(1007, 35)) End WithEnd Withi = 1Dates(1) = DateSerial(2006, 1, 15)x = Application.VLookup(CLng(Dates(i)), TestRng, 3)MsgBox xEnd Sub'''''''''''''''''''''''''''''''''''''''''''
Last edited by
MMP on January 6th, 2007, 11:00 pm, edited 1 time in total.