Click here to Skip to main content
15,887,283 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I tried following however its giving me sytax error which I am unable to rectify:

VB:
 
For i = 1 To 11 
    Range("D" & i).Value = WorksheetFunction.VLookup(A2, Sheet2!A$1:G$14, 7, False) 
Next i 


its giving me compile error msg as follwing
Compile Error: Expected list seperator or )

and digit one in A$1 of Vlookup function gets highlighted.

Hope I understood your reply or probably I need to change something in my code.
Posted
Comments
fjdiewornncalwe 22-Aug-13 9:48am    
It may be that you need to wrap the VLookup arguments as strings.
i.e. WorksheetFunction.VLookup("A2", "Sheet2!A$1:G$14", 7, False)
I'm only guessing, so I may be wrong on this.
Saksham_Agrawal 23-Aug-13 9:02am    
No Dude its not working this way.

1 solution

Have a look here: WorksheetFunction.VLookup Method (Excel)[^].

VB
Dim dstWsh as Worksheet, srcWsh AS Worksheet
Set dstWsh = Thisworkbook.Worksheets("Sheet1")
Set srcWsh = Thisworkbook.Worksheets("Sheet2")

For i = 1 To 11
    dstWsh.Range("D" & i).Value = WorksheetFunction.VLookup(dstWsh.Range("A2"), srcWsh.Range("A$1:G$14"), 7, False)
Next i
 
Share this answer
 
Comments
Saksham_Agrawal 23-Aug-13 9:01am    
Unable to get the Vlookup property of the WorkSheetfunction.
error code: 1004

Have you checked this? Is this working on your system?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900