Consulting

Results 1 to 5 of 5

Thread: Vlookup using Vba code across two tabs

  1. #1
    VBAX Regular
    Joined
    Dec 2015
    Posts
    11
    Location

    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

    Captu.JPG


    Tab 2


    Care.JPG
    Attached Files Attached Files

  2. #2
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,876
    Not a 100% sure which way the data are going but test:
    Sub blah()
    With Sheets("Base Sheet").Range("AE2:AE3541")
      .FormulaR1C1 = "=VLOOKUP(RC[-30],ottwafield!R1C1:R36C2,2,FALSE)"
      .Value = .Value
      .SpecialCells(xlCellTypeConstants, 16).ClearContents
    End With
    End Sub
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

  3. #3
    VBAX Regular
    Joined
    Dec 2015
    Posts
    11
    Location
    Thanks Friend...its working fine ...major change was the data set was dynamic in nature.

    the below code works for the above requirement...Appreciate your help on this...thank you .



    Sub test()
    Range("a2", Range("a" & Rows.Count).End(xlUp)).Columns("ae:af").Formula = _
    "=iferror(vlookup($a2,ottwafield!$a:$b,column(a1),false),"""")"
    EndSub

  4. #4
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,876
    I needn't have bothered. You already had the answer.
    You cross posted at Chandoo.org, which you do regularly… (as well as MrExcel at times) without providing links.
    All forums have the same or similar rules on cross posting.

    Have a read of: http://www.excelguru.ca/content.php?184
    And please supply links in future.

  5. #5
    VBAX Regular
    Joined
    Dec 2015
    Posts
    11
    Location
    Sure Friend ...sorry for the confusion.
    Going Forward will supply links ...Apologies again

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •