Hi everybody, my VLookUp function is working so far, now I would like to convert it into a VBA function.
My VLookUp:
=VLOOKUP(A6;'[test.xls]Sheet1'!$A:$B;2;0) 'example for Cell A6, which can vary
Now I would like to get this into a VBA function which can be called. So if the function is called "A6" sould be "overwriten" by the left cell of where the function has been called.
I have tried following code:
Sub lookup()
Dim x1 As String
x1 = ActiveCell.Offset(0, -1).Select
VLOOKUP(x1,'[test.xls]Sheet1'!$A:$B;2;0)
End Sub
What is necessary that it's working as expected?
I'm grateful for any tips.
Update:
Sorry, mabye it wasn't clear. "test.xls" is another workbook. The code should run inside the file called (e.g.) "missing.xls".
VLookUpon, is it in the same workbook or a different workbook? from your example, it looks like your range is intest.xlsworkbook, which may or may not be the same workbook?