Using Vlookup to match data

mermaidGurl

New Member
Joined
Sep 12, 2017
Messages
5
hii,

So what I'm trying to do goes as follows:

----SETUP----

i have a first workbook named "countrycodes.xlsx" that has 1 sheet with two columns. first column refers to "country code" (which is also the header A1) , the second column refers to the "country name" (header B1).

i have a second workbook that includes all sort of data about different species with infinite number of sheets. all sheets have the same headers, one of which include "country code". the sheets already include the country code but not the country name.

---GOAL----

i would like to create a macro that takes the country code from second workbook, searches for the corresponding country name of that country code in the first workbook and then places that country name in the column to the right of the country code (which is an empty country name column).

i would like to fill in the entire country name column in this way.

-------------

I am new to VBA. I would greatly appreciate some help, and if you can explain what you did that would be even better.

Thank you so much, :-?

mermaidGurl
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
in the first sheet, say in Z1, put a country code from sheet1 in the second workbook, and in AA1 do a lookup to get the country name, copy it, and paste it in sheet1. Do this for every row in sheet1, than move to the second sheet. Say you have 10 sheets...

for j=1 to 10
sheets(j) select
for k=1 to 1000
temp=cells(k,1)
.....open first workbook
cells(1,26)=temp
temp2=cells(1,27)
.....close first workbook
cells(k,2)=temp2
next k
next j

does this give you ideas / get ,you started ?
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,175
Members
453,021
Latest member
Justyna P

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
Back
Top