![]() |
Do I have superfluous code?
The code below is in a workbook called "Data Storage and Retrieval" which
recieves copied worksheets from another "Data Collection" workbook. To avoid the runtime error involved with continuously copying worksheets without closing the workbook I have some OnTime timers to save and copy both workbooks. My question is: after the line of code below closes the workbook it came from (Data Storage and Retrieval) is the rest of the code executed since Excel is still open or is the routine ended at that point (in which case I don't need the following lines of code)? Thanks. Sub Storage() Application.Run "'DATA STORAGE AND RETRIEVAL.xls'!StopTimer_Store" Application.Run "'DATA COLLECTION.xls'!StopTimer_Collect" WaitTime1 = Now + TimeValue("0:00:03") Application.Wait WaitTime1 Application.DisplayAlerts = False Workbooks("DATA COLLECTION").SaveAs ("P:\Bowling Green\QA DATA\QA DATA COLLECTION\DATA COLLECTION.xls") Workbooks("DATA COLLECTION").Close SaveChange = False Workbooks("DATA STORAGE AND RETRIEVAL").SaveAs ("P:\Bowling Green\QA DATA\QA DATA COLLECTION\DATA STORAGE AND RETRIEVAL.xls") Workbooks.Open ("P:\Bowling Green\QA DATA\QA DATA COLLECTION\DATA COLLECTION.xls") Workbooks("DATA STORAGE AND RETRIEVAL").Close SaveChange = False Application.DisplayAlerts = True Application.Run "'DATA COLLECTION.xls'!StartTimer_Collect" Application.Run "'DATA STORAGE AND RETRIEVAL.xls'!StartTimer_Store" End Sub -- n00b lookn for a handout :) |
Do I have superfluous code?
I can't tell which workbook the macro is running. If you close the worksheet
that is running a macro the macro stops running. close overides the completion of running a macro. "Arnie" wrote: The code below is in a workbook called "Data Storage and Retrieval" which recieves copied worksheets from another "Data Collection" workbook. To avoid the runtime error involved with continuously copying worksheets without closing the workbook I have some OnTime timers to save and copy both workbooks. My question is: after the line of code below closes the workbook it came from (Data Storage and Retrieval) is the rest of the code executed since Excel is still open or is the routine ended at that point (in which case I don't need the following lines of code)? Thanks. Sub Storage() Application.Run "'DATA STORAGE AND RETRIEVAL.xls'!StopTimer_Store" Application.Run "'DATA COLLECTION.xls'!StopTimer_Collect" WaitTime1 = Now + TimeValue("0:00:03") Application.Wait WaitTime1 Application.DisplayAlerts = False Workbooks("DATA COLLECTION").SaveAs ("P:\Bowling Green\QA DATA\QA DATA COLLECTION\DATA COLLECTION.xls") Workbooks("DATA COLLECTION").Close SaveChange = False Workbooks("DATA STORAGE AND RETRIEVAL").SaveAs ("P:\Bowling Green\QA DATA\QA DATA COLLECTION\DATA STORAGE AND RETRIEVAL.xls") Workbooks.Open ("P:\Bowling Green\QA DATA\QA DATA COLLECTION\DATA COLLECTION.xls") Workbooks("DATA STORAGE AND RETRIEVAL").Close SaveChange = False Application.DisplayAlerts = True Application.Run "'DATA COLLECTION.xls'!StartTimer_Collect" Application.Run "'DATA STORAGE AND RETRIEVAL.xls'!StartTimer_Store" End Sub -- n00b lookn for a handout :) |
Do I have superfluous code?
Thanks Joel.
I believe I need to clean up a lot of un-needed lines. -- n00b lookn for a handout :) "Joel" wrote: I can't tell which workbook the macro is running. If you close the worksheet that is running a macro the macro stops running. close overides the completion of running a macro. "Arnie" wrote: The code below is in a workbook called "Data Storage and Retrieval" which recieves copied worksheets from another "Data Collection" workbook. To avoid the runtime error involved with continuously copying worksheets without closing the workbook I have some OnTime timers to save and copy both workbooks. My question is: after the line of code below closes the workbook it came from (Data Storage and Retrieval) is the rest of the code executed since Excel is still open or is the routine ended at that point (in which case I don't need the following lines of code)? Thanks. Sub Storage() Application.Run "'DATA STORAGE AND RETRIEVAL.xls'!StopTimer_Store" Application.Run "'DATA COLLECTION.xls'!StopTimer_Collect" WaitTime1 = Now + TimeValue("0:00:03") Application.Wait WaitTime1 Application.DisplayAlerts = False Workbooks("DATA COLLECTION").SaveAs ("P:\Bowling Green\QA DATA\QA DATA COLLECTION\DATA COLLECTION.xls") Workbooks("DATA COLLECTION").Close SaveChange = False Workbooks("DATA STORAGE AND RETRIEVAL").SaveAs ("P:\Bowling Green\QA DATA\QA DATA COLLECTION\DATA STORAGE AND RETRIEVAL.xls") Workbooks.Open ("P:\Bowling Green\QA DATA\QA DATA COLLECTION\DATA COLLECTION.xls") Workbooks("DATA STORAGE AND RETRIEVAL").Close SaveChange = False Application.DisplayAlerts = True Application.Run "'DATA COLLECTION.xls'!StartTimer_Collect" Application.Run "'DATA STORAGE AND RETRIEVAL.xls'!StartTimer_Store" End Sub -- n00b lookn for a handout :) |
All times are GMT +1. The time now is 07:45 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com