PDA

View Full Version : VBA merge from some open and some closed workbooks



tx7399
10-21-2012, 04:27 AM
Hi everyone,

I have macros (adapted from contributions by Ron DeBruin) that process all workbooks in a folder. First, a source workbook is opened, then a filter (based on a date) is applied, then the filtered results are written to a worksheet in the controlling workbook. The code continues to process all the workbooks in the folder.

All works well if all the source workbooks are closed at the time the merge macro is run. If, however, one of the source workbooks is open the processing is interrupted by a popup that says, "whatever.xlsm is already open. Reopening will cause any changes you made to be discarded. Do you want to reopen whatever.xlsm?"

If I answer 'No', the work book is skipped.
If I answer 'Yes', the workbook opens, gets filtered, and its data is included in the merge target worksheet.

Now to my questions. The source folder is located on a network shared drive. If another user had his workbook open and was making entries (these would be entries for a different date than the date being filtered) would changes he made be lost when my code closes the workbook after processing? or does the code only close its copy and all is okay in the source workbook?

Regards,