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

Vlookup using Vba code across two tabs

Hi Friends

I am trying to implement the excel vlookup function into my vba command.
I have a sheet with 2 tabs :

Tab 1 = "Base sheet" has 3 columns
Tab 2 = "ottwafield" has 2 columns.

We have to do a vlookup from Tab 1 to Tab 2 to get the data points from Tab 2.

Tab 1

upload_2016-2-6_22-10-24.png


Tab 2


upload_2016-2-6_22-9-42.png
 

Attachments

  • sample 2.xlsm
    50.9 KB · Views: 20
Not sure if this is how you wanted.
Code:
Sub test()
    Range("a2", Range("a" & Rows.Count).End(xlUp)).Columns("ae:af").Formula = _
    "=iferror(vlookup($a2,ottwafield!$a:$b,column(a1),false),"""")"
End Sub
 
Thanks Jindon...a very small change, for all the false cases can we get "#NA" instead of Blanks.

Thank you for your uncondtional help
 
Just delete IfError function....
change
Code:
"=iferror(vlookup($a2,ottwafield!$a:$b,column(a1),false),"""")"
to
Code:
"=vlookup($a2,ottwafield!$a:$b,column(a1),false)"
 
Back
Top