Retrieve Cell Value from multiple workbooks using a reference cell locations

sanilmathews

Board Regular
Joined
Jun 28, 2011
Messages
102
Hi All,

I have the below code which will allow the user to retrieve the data from an external workbook by just providing the path in Sheet1.Range ("B2") in the active workbook.

Would like to have the below code re-written by applying a loop, where column B in the active workbook will have path-reference of multiple files. The code should take in each path in column B starting from B2 to fetch the data in A1 cell of Sheet1 of every workbook until the last path referred in Column B of active workbook.

Thanks in advance!

Code:
Dim XL As Excel.Application
 
Dim WBK As Excel.Workbook
 
Dim Location As String
 
Location = ActiveWorkbook.Sheets("Sheet1").Range("B2").Value
 
Set XL = CreateObject("Excel.Application")
 
Set WBK = XL.Workbooks.Open(Location)
 
ActiveWorkbook.Sheets("Sheet1").Range("A2") = WBK.Sheets("MasterInput").Range("A1").Value
 
WBK.Close
 
Set XL = Nothing
 
Last edited:

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes

Forum statistics

Threads
1,223,911
Messages
6,175,327
Members
452,635
Latest member
laura12345

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