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
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