Hi,
I have a very confusing problem, my vlookup function in vba does not find the closest date in a sorted data set containing dates. It does so when i apply it to a cell using the exact same data range, the exact same date and the exact same data. my code is simply:
rngname = activeworkbook.sheets(shtnbr).cells(5,19) ' Data name
tempname = range(rngname).worksheet.name
r = ActiveWorkbook.Worksheets(tempname).Range(rngName)
msgbox Application.VLookup(ActiveWorkbook.Sheets(shtNbr).Cells(19, 4).Value, r, 1)
where the cell value in cell(19,4) is the date and rngname is the range to search.
What could possibly be wrong in my code? I find it very weird that it does work when i apply it to a cell but not in my code...
Thanks!
Bookmarks