VLookup in VBA
Am trying to use the VLookup function in VBA code, and the
following line won't run: intPointValue = Application.WorksheetFunction.VLookup (varRawData, Worksheets(2).Range("LFLookup"), 9, True) I get runtime error 1004, "Unable to get the VLookup property of the WorksheetFunction class." What am I missing? I tried several variations but can't seem to make VLookup work, even though the Help says it will. Any hints most appreciated. |
VLookup in VBA
If LFLookup is a variable, then you should not put quotes
around it. -----Original Message----- Am trying to use the VLookup function in VBA code, and the following line won't run: intPointValue = Application.WorksheetFunction.VLookup (varRawData, Worksheets(2).Range("LFLookup"), 9, True) I get runtime error 1004, "Unable to get the VLookup property of the WorksheetFunction class." What am I missing? I tried several variations but can't seem to make VLookup work, even though the Help says it will. Any hints most appreciated. . |
VLookup in VBA
Hi Larry;
On thing to look at is that in the code below it has Worksheets(2) which is referring to the sheet by index. I would try switching it to the actual name such as WorkSheets("MyWorkSheetName") Thanks, Greg -----Original Message----- Am trying to use the VLookup function in VBA code, and the following line won't run: intPointValue = Application.WorksheetFunction.VLookup (varRawData, Worksheets(2).Range("LFLookup"), 9, True) I get runtime error 1004, "Unable to get the VLookup property of the WorksheetFunction class." What am I missing? I tried several variations but can't seem to make VLookup work, even though the Help says it will. Any hints most appreciated. . |
VLookup in VBA
intPointValue = Application.VLookup(varRawData, _
Worksheets(2).Range("LFLookup"), 9, True) Using just application will often allow it to work. -- Regards, Tom Ogilvy "LarryP" wrote in message ... Am trying to use the VLookup function in VBA code, and the following line won't run: intPointValue = Application.WorksheetFunction.VLookup (varRawData, Worksheets(2).Range("LFLookup"), 9, True) I get runtime error 1004, "Unable to get the VLookup property of the WorksheetFunction class." What am I missing? I tried several variations but can't seem to make VLookup work, even though the Help says it will. Any hints most appreciated. |
VLookup in VBA
If "LFLookup" is a range in the worksheet replace the quotes with square braces.
eg.... .Range([LFLookup]), etc -- Paul M "LarryP" wrote: Am trying to use the VLookup function in VBA code, and the following line won't run: intPointValue = Application.WorksheetFunction.VLookup (varRawData, Worksheets(2).Range("LFLookup"), 9, True) I get runtime error 1004, "Unable to get the VLookup property of the WorksheetFunction class." What am I missing? I tried several variations but can't seem to make VLookup work, even though the Help says it will. Any hints most appreciated. |
VLookup in VBA
that would cause an error.
Either ..Range("LFLookup"), or [LFLookup] would work, but not combined. Since there is nothing wrong with that part of the code as written (as long as LFLookup is on worksheets(2)) then there is no reason to change it. -- Regards, Tom Ogilvy "Twoo Doggs" wrote in message ... If "LFLookup" is a range in the worksheet replace the quotes with square braces. eg.... .Range([LFLookup]), etc -- Paul M "LarryP" wrote: Am trying to use the VLookup function in VBA code, and the following line won't run: intPointValue = Application.WorksheetFunction.VLookup (varRawData, Worksheets(2).Range("LFLookup"), 9, True) I get runtime error 1004, "Unable to get the VLookup property of the WorksheetFunction class." What am I missing? I tried several variations but can't seem to make VLookup work, even though the Help says it will. Any hints most appreciated. |
All times are GMT +1. The time now is 07:13 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com