PDA

View Full Version : Macro to open and update several workbooks



Flupsie
08-07-2014, 08:51 AM
I have the following code which is used to open up workbooks one by one and to update these . The source workbooks in CSV format are in the folder C:\downloads. However, I need to open each file individually and then select the file in C:\downloads in order for the destination file to be updated

The downloaded files are in C:\downloads and the destination workbooks are in C:\Parts & SVC Sales

The workbooks in C:\Parts & SVC Sales contains and name and division

for eg Br1 parts sales , Br1 Service Sales

When opening the files , the files for parts sales for EG Br1 Parts Sales must be updated to file containing a similar name (in C:\downloads) and must contain in the file name "salesperson" for eg Br1 Salesperson 01-07-2014


When opening the files , the files for service sales for eg Br1 Service sales must be updated to file containing a similar name (in C:\downloads) + must contain in the file name "" for eg Br1 Service ooder repair register 01-07-2014

When comparing the name in the distination file to the source file, the name can be anywhere in the source file


Sub Update_Workbooks()
ChDir ("C:\Parts & SVC Sales")
Application.DisplayAlerts = False
fPath = Application.GetOpenFilename
fName = Mid(fPath, Len("C:\Parts & SVC Sales") + 2)
Workbooks.Open (fPath)
Application.Run "'" & fName & "'!Auto_Update"
ActiveWorkbook.Save
ActiveWorkbook.Close
CloseCSV
End Sub

See link to file examples


https://www.dropbox.com/s/dwf8ytgnnf79uia/Dropbox.rar

Your assistance in opening and updating the files simultaneously is much appreciated