Syntax Error in VLOOKUP Code

G

Guest

I have the following code as part of a larger macro.

For ILoop = NumRowsIFCAP To 1 Step -1

IF(ISERROR(VLOOKUP(Cells(Iloop,1),FileOpenNameF850!$A$1:$C$NumRowsF850,2,FALSE))) then
(More code...)
End If
Next Iloop

"FileOpenNameF850" is a string variable that holds a workbook name that
contains one worksheet.

I can't get the syntax correct in the VLOOKUP line of code. What is the
correct syntax?

TIA.
 
T

Tom Ogilvy

Assume FileOpenName850 is like "myfile.xls" and not
"C:\Myfolder\Myfile.xls"

You don't specify which worksheets, so assume the first

Dim rng as Range
Set rng = Workbooks(FileOpenName850).worksheets(1).Range("A1:C" &
NumRowsF850)
For ILoop = NumRowsIFCAP to 1 Step -1
if iserror(Application.Vlookup(Cells(ILoop,1),rng,2,False)) then

--
Regards,
Tom Ogilvy




IF(ISERROR(VLOOKUP(Cells(Iloop,1),FileOpenNameF850!$A$1:$C$NumRowsF850,2,FAL
SE)))
Ken said:
I have the following code as part of a larger macro.

For ILoop = NumRowsIFCAP To 1 Step -1
IF(ISERROR(VLOOKUP(Cells(Iloop,1),FileOpenNameF850!$A$1:$C$NumRowsF850,2,FAL
SE))) then
 
G

Guest

Thanks, Tom.
Been a while since I was on this newsgroup and thought I was at the "wrong
house" at first. Glad you are still here helping!
 
T

Tom Ogilvy

Welcome back!

--
Regards,
Tom Ogilvy

Ken said:
Thanks, Tom.
Been a while since I was on this newsgroup and thought I was at the "wrong
house" at first. Glad you are still here helping!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top