How to link data from multiple worksheets which uses the same cells values

Corried

Board Regular
Joined
Dec 19, 2019
Messages
217
Office Version
  1. 2019
Platform
  1. Windows
  2. Web
Hello Excel World:

I have a problem.

I want to extract data to create a list from workbook (B) into another workbook (A).

NB: Using the "=" sign is hard and long to extract data.

So my point is:
On workbook (A), I have a list of countries names from row A2 to row A51
Next. On workbook (B). Each country has it own "worksheet". From worksheet #1 to Worksheet #50 and all the values are in cells "F2 & G2" respectively.
I want excel to grab each worksheet values in "F2 & G2" in workbook (B) and paste it as a list in workbook (A) in worksheet (1).

How can I do that?
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Put this code into workbook A and then change the line:
Workbooks("Book2").Activate to what ever the name of workbook B is.
VBA Code:
Sub test()
wbname = ActiveWorkbook.Name
countries = Range("A2:A51")
outarr = Range(("B2:C51"))

Workbooks("Book2").Activate
For i = 1 To 50
If countries(i, 1) <> "" Then
Worksheets(countries(i, 1)).Select
  temp = Range("F2:G2")
  outarr(i, 1) = temp(1, 1)
  outarr(i, 2) = temp(1, 2)
End If
Next i
Workbooks(wbname).Activate
Worksheets(1).Select
Range(("B2:C51")) = outarr

End Sub
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,241
Members
452,622
Latest member
Laura_PinksBTHFT

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