• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Vlook up with Macro

Babin Das

New Member
Hi I am trying to vlookup from sheet2 to sheet lookup, I have written the following code for the same, but it showing error 1008 for set statement and error for formula statement. Can you please rectify the code.

Thanks in advance.

The code is as follows

Sub Lookup()
Dim LW1 As Long, LW2 As Long, I As Long, J As Long, Lookup_Value As Long, Rag As Range
'Sheets("Sheet2").Active

LW1 = Sheets("Sheet2").Cells(Rows.Count, 1).End(xlUp).Row
For I = 2 To LW1
Set Rag = Sheets("Sheet2").Range(Cells(I, 2), Cells(I, 5)).Address

LW2 = Sheets("Lookup").Cells(Rows.Count, 1).End(xlUp).Row
For J = 2 To LW2
Lookup_Value = Sheets("Lookup").Range("C" & J)
Sheets("Lookup").Activate
Application.WorksheetFunction.Cells("C" & J) = "=Vlookup(Lookup_Value,Rag,2,""False"")"
Next J
Next I
End Sub
 

Attachments

  • Vlookup_fr_multi.xlsx
    13.7 KB · Views: 0
Yes sir,

you are right, but i would like to know what is wrong with my code as i am very beginner in vba. My main pont related about the following line
Application.WorksheetFunction.Cells("C" & J) = "=Vlookup(Lookup_Value,Rag,2,""False"")"

Thanks in advance
 
Hi ,

Quite a few things !

You should go through the changed code , and see all the differences , and make an attempt to understand.

The syntax of the Cells method is wrong , the method Formula is missing , the syntax of the formula itself is wrong ...

Explaining all this is going to take time ; if you can wait , I will explain.

Narayan
 
Back
Top