Macro to vlookup multiple columns

Keshav14

New Member
Joined
Jul 1, 2019
Messages
1
Hi,

I need to populate almost 10 columns with information from another excel sheet. We usually do it using vlookup.
Can we use a macro and automate it. SO that I just click once and all the columns gets populates.

Table A where the information needs to be populated
IPLocationMetal categoryTeamsApplication HostedOwner
1.1.1.1
1.1.1.2
1.1.1.3
1.1.1.2

<tbody>
</tbody>









Table B which contains information which is required in table A
IPLocationMetal CategoryTeamsApplication HostedOwner
1.1.1.1UKIronWindowsMS OutlookA
1.1.1.2USAIronUnixEmailB
1.1.1.3AustraliaGoldUnixSharepointA
1.1.1.4UKSilverUnixSharepointA
1.1.1.5IndiaBronzeWindowsVmwareC

<tbody>
</tbody>












Regards,
Keshav
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
59,920
Office Version
  1. 365
Platform
  1. Windows
How about
Code:
Sub Keshav14()
    Dim Cl As Range
    Dim Ws1 As Worksheet, Ws2 As Worksheet
    
    Set Ws1 = Sheets("sheet1")
    Set Ws2 = Sheets("sheet2")
    With CreateObject("scripting.dictionary")
        For Each Cl In Ws2.Range("A2", Ws2.Range("A" & Rows.Count).End(xlUp))
            .Item(Cl.Value) = Cl.Offset(, 1).Resize(, [COLOR=#ff0000]5[/COLOR])
        Next Cl
        For Each Cl In Ws1.Range("A2", Ws1.Range("A" & Rows.Count).End(xlUp))
            Cl.Offset(, 1).Resize(, [COLOR=#ff0000]5[/COLOR]).Value = .Item(Cl.Value)
        Next Cl
    End With
End Sub
Change the values in red to match the number of columns you want to copy.
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
59,920
Office Version
  1. 365
Platform
  1. Windows
Cross posted https://www.excelforum.com/excel-pr...281146-macro-to-vlookup-multiple-columns.html

While we do not prohibit Cross-Posting on this site, we do ask that you please mention you are doing so and provide links in each of the threads pointing to the other thread (see rule 13 here along with the explanation: Forum Rules).
This way, other members can see what has already been done in regards to a question, and do not waste time working on a question that may already be answered.
 

Forum statistics

Threads
1,136,314
Messages
5,675,032
Members
419,544
Latest member
MVPDoug

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top