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!
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: