ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Syntax Error in VLOOKUP Code (https://www.excelbanter.com/excel-programming/314156-syntax-error-vlookup-code.html)

Ken

Syntax Error in VLOOKUP Code
 
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.


Tom Ogilvy

Syntax Error in VLOOKUP Code
 
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,F alse)) then

--
Regards,
Tom Ogilvy




IF(ISERROR(VLOOKUP(Cells(Iloop,1),FileOpenNameF850 !$A$1:$C$NumRowsF850,2,FAL
SE)))
"Ken" wrote in message
...
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
(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.




Ken

Syntax Error in VLOOKUP Code
 
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!

"Tom Ogilvy" wrote:

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,F alse)) then

--
Regards,
Tom Ogilvy




IF(ISERROR(VLOOKUP(Cells(Iloop,1),FileOpenNameF850 !$A$1:$C$NumRowsF850,2,FAL
SE)))
"Ken" wrote in message
...
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
(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.





Tom Ogilvy

Syntax Error in VLOOKUP Code
 
Welcome back!

--
Regards,
Tom Ogilvy

"Ken" wrote in message
...
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!

"Tom Ogilvy" wrote:

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,F alse)) then

--
Regards,
Tom Ogilvy





IF(ISERROR(VLOOKUP(Cells(Iloop,1),FileOpenNameF850 !$A$1:$C$NumRowsF850,2,FAL
SE)))
"Ken" wrote in message
...
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
(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.








All times are GMT +1. The time now is 12:19 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com