Hi Team,
I am trying different option of using vlookup. only single formula working. when I use defined my criteria range as MyData
other are showing errors. please assist where its going wrong.
My Criteria range is in sheet3 (c6:f11) , my lookupvalue is in sheet1(a2), I am running vlookup in sheet1("b2").
Please assist.
below are my code.
Option Explicit
Sub Pranay()
Dim rs As Range
Dim lr As Long
lr = Cells(Rows.Count, 1).End(xlUp).Row
Set rs = ThisWorkbook.Sheets(3).Range("C6:F11").Value
'Sheets(1).Range("b2:b" & lr).Formula = "=vlookup(a2,MyData,2,false)"
Sheets(1).Range("b2:b" & lr).Formula = "=vlookup(a2,rs,2,0)"
'Sheets(1).Range("b2:b" & lr).Formula = "=vlookup(a2,sheets(3).range("C6:F11").value,2,false)"
Sheets(1).Range("b2:b" & lr).Formula = "=vlookup(sheets(1).range("a2"),sheets(3).range("C6:F11").value,2,false)"<strike></strike>
<strike></strike>
End Sub
I am trying different option of using vlookup. only single formula working. when I use defined my criteria range as MyData
other are showing errors. please assist where its going wrong.
My Criteria range is in sheet3 (c6:f11) , my lookupvalue is in sheet1(a2), I am running vlookup in sheet1("b2").
Please assist.
below are my code.
Option Explicit
Sub Pranay()
Dim rs As Range
Dim lr As Long
lr = Cells(Rows.Count, 1).End(xlUp).Row
Set rs = ThisWorkbook.Sheets(3).Range("C6:F11").Value
'Sheets(1).Range("b2:b" & lr).Formula = "=vlookup(a2,MyData,2,false)"
Sheets(1).Range("b2:b" & lr).Formula = "=vlookup(a2,rs,2,0)"
'Sheets(1).Range("b2:b" & lr).Formula = "=vlookup(a2,sheets(3).range("C6:F11").value,2,false)"
Sheets(1).Range("b2:b" & lr).Formula = "=vlookup(sheets(1).range("a2"),sheets(3).range("C6:F11").value,2,false)"<strike></strike>
<strike></strike>
End Sub