Hi everyone,
With a lot of help from you guys, I have developed a macro enabled workbook that handles updating inventory on my website. However, it got to the point it was so big and complex, it was taking too long to run, was extremely difficult to modify (due to all of the references and the time it takes to update all calcs), and was even unstable at times. I noticed I was getting odd results, and read where Excel can become unstable when the file size exceeds 50mb. This one exceeds 70...
So, I broke it down into multiple workbooks. So far, I only have 2 workbooks, but intend to add at least one more, if not 2 or 3 more. The idea is to open my primary "UpdateWorkbook.xslm" with windows task manager. From there, the auto run macro will perform some tasks (download updated inventory data), then run my individual workbooks (each with an autorun macro), then upload the updated information.
The uploading and downloading data is working fine. The individual workbooks that I want to automate the opening/running of are working as expected too. Opening the other macro enabled workbooks seems to be the problem. I had a similar code developed for saving as a file type, so I tried to use that code. That code is below. The beauty of it is it looks at columns on a sheet in the workbook to determine what files to open. So, as I add more workbooks in the future, I can just include their name on that sheet and we are good to go without having to hard code anything else.
Any ideas who I can make the secondary macro enabled workbooks open with code, run, close, and then move on to the next one on the list?
With a lot of help from you guys, I have developed a macro enabled workbook that handles updating inventory on my website. However, it got to the point it was so big and complex, it was taking too long to run, was extremely difficult to modify (due to all of the references and the time it takes to update all calcs), and was even unstable at times. I noticed I was getting odd results, and read where Excel can become unstable when the file size exceeds 50mb. This one exceeds 70...
So, I broke it down into multiple workbooks. So far, I only have 2 workbooks, but intend to add at least one more, if not 2 or 3 more. The idea is to open my primary "UpdateWorkbook.xslm" with windows task manager. From there, the auto run macro will perform some tasks (download updated inventory data), then run my individual workbooks (each with an autorun macro), then upload the updated information.
The uploading and downloading data is working fine. The individual workbooks that I want to automate the opening/running of are working as expected too. Opening the other macro enabled workbooks seems to be the problem. I had a similar code developed for saving as a file type, so I tried to use that code. That code is below. The beauty of it is it looks at columns on a sheet in the workbook to determine what files to open. So, as I add more workbooks in the future, I can just include their name on that sheet and we are good to go without having to hard code anything else.
Any ideas who I can make the secondary macro enabled workbooks open with code, run, close, and then move on to the next one on the list?
Code:
counter = 2 'initialize variable
Sheets("Files to Run").Select
Range("a2").Select '1st cell with file name
Do Until ActiveCell = "" 'do until condition
fname1 = Cells(counter, 1) 'selects cell with file name
'this is set for column A
filext = Cells(counter, 2) 'define file extension
fnamesuffix = Cells(counter, 3) 'define file extension
FileFormatVar = Cells(counter, 4) 'define file extension
fname = directory & fname1 & fileext 'file location
Workbooks.Open Filename:=fname 'open the xls file
ActiveWorkbook.Close SaveChanges:=False 'close WB
Windows("UpdateWorkbook.xlsm").Activate 'select workbook with file info
Sheets("Files to Run").Select 'select sheet with file info
counter = counter + 1
ActiveCell.Offset(1, 0).Range("a1").Select 'This moves down the column