PC Review


Reply
Thread Tools Rate Thread

Do I have superfluous code?

 
 
=?Utf-8?B?QXJuaWU=?=
Guest
Posts: n/a
 
      19th Sep 2007
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
 
Reply With Quote
 
 
 
 
=?Utf-8?B?Sm9lbA==?=
Guest
Posts: n/a
 
      19th Sep 2007
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

 
Reply With Quote
 
=?Utf-8?B?QXJuaWU=?=
Guest
Posts: n/a
 
      19th Sep 2007
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

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Superfluous User =?Utf-8?B?S0Nhdg==?= Windows XP General 6 23rd Jun 2007 12:56 AM
Superfluous information Terry Bennett Windows XP Basics 15 5th Feb 2006 02:16 AM
Superfluous folders Jerry Windows XP Performance 6 7th Aug 2005 11:00 PM
Superfluous labels newsgroupie Microsoft C# .NET 4 1st Dec 2004 07:10 PM
Get rid of superfluous comments JeffO Windows XP Customization 0 20th Jan 2004 04:22 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:01 PM.