Not enough code or context to provide a diagnosis. The code for VLOOKUP looks OK, but the error could be happening in several places.
Is the file Workbooks(Name) open at the point where it is used? If the file is not open, the code will fail. Although Excel formulas can refer to external files without the file being open, VBA code cannot use a range expression like
if the file is not open.
How are these variables declared? At the point where the error occurs, what are the values of these variables?
Bookmarks