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

Application.WorksheetFunction.VLookup code wrong

Hi i am using the excel 2013

i have got error the vlooup VBA function

Range("C2:C" & lRow).Formula = Application.WorksheetFunction.VLookup(Sheets("Master").Range("$B2"), Sheets("Master").Range("$K$2:$L$" & lRow1), 2, False)

Kindly help for itself

Regards.,
K.Sivaprakasam
 

Attachments

  • Vlookup.xlsm
    444.3 KB · Views: 4
You are trying to execute the VLookup function in VBA by using Application.Worksheetfunction

What you need to do is save the Formula as a text string representing the formula into the cells

Change the line to read as below

Code:
Range("C2:C" & lRow).Formula = "=VLookup($B2, $K$2:$L$" + CStr(lRow1) + ", 2, False)"
 
CStr() is Convert String
so CStr(lRow1) converts the number lRow1 froma Number to a Text value for us in the remainder of the formula

In VBA click on CStr and press F1 for an explanation of the function
 
Back
Top