The user is trying to write a macro that inserts a VLOOKUP formula into a cell. The issue is that the array that the VLOOKUP references will be on a different spreadsheet each time. The user can get the file name from the open file dialog which is chosen by the user. The user hasn't written that part yet because the user is not sure whether the final part of inserting the formula is possible.
The formula will be inserted like this:
So, how would the user insert the SheetSpecifiedByUser part into the formula?
Range("B10").Value = "=VLOOKUP(A10,'[" & Filename & "]sheet1'!A:B,2,0)"
Obtained from the OzGrid Help Forum.
Solution provided by vba_monkey
|How to use VLOOKUP (example)|
|How to use the VLOOKUP formula|
|How to use IF and VLOOKUP formulas together|
|How to maintain the VLOOKUP font format|