Home > Forum Home > Managing Supply Chain and Inventory > update a workbook from many others > Create links or use VBA Share

Create links or use VBA

Excel Help for Create Links Or Use Vba in Managing Supply Chain and Inventory


Forum TopicLogin

Create Links Or Use Vba

Rate this:
(4/5 from 2 votes)
HappyYou can either create formulas to link in data from each workbook in the directory or create a VBA macro that loops through the files in the directory and extracts data into a master workbook.

To create the macro you need to use some VBA code such as the following.
VBA Code:
Sub ImportFiles()
Dim sh as Worksheet, sPath as String, sName as String
Dim r as Range, fName as String
set sh = Activesheet
sPath = "C:\Myfolder\MyTextfiles\"
sName = Dir(sPath & "*.txt")  ' or ".CSV" - whatever is appropriate
do while sname <> ""
 set fname = sPath & sname
 set r = sh.Cells(rows.count,1).end(xlup)
 ' now the recorded code with r used to specify the import location
 ' and fname used to specify the file name
 sName = dir()
Loop
End sub

 Excel Business Forums Administrator
 Posted by on
 
View Full Post

Find relevant Excel templates and add-ins for Create links or use VBA in the