Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default Run macro in background

I have several macros that I run each day, some of which take up to an hour
to complete. Whilst they are running I cannot use Excel. Is there a way to
run macros in the background or, better still, have them run during the night
like a cron job in UNIX ???

Many thanks for any help.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default Run macro in background

you can use the Windows Task Scheduler to run the macro at whatever time you
like

Alternatively, use a separate instance of Excel.

"JLR-Mart" wrote:

I have several macros that I run each day, some of which take up to an hour
to complete. Whilst they are running I cannot use Excel. Is there a way to
run macros in the background or, better still, have them run during the night
like a cron job in UNIX ???

Many thanks for any help.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Run macro in background

You can always code your macros to "share focus". This way they will not hog
the processor, but let you get some work done as well.

for example:

Sub RunForever()
Do
Loop
End Sub

is a real hog, however:

Sub RunUntil()
Do
DoEvents
If Range("A1").Value < "" Then
MsgBox ("I am stopping now.")
Exit Sub
End If
Loop
End Sub

is a good citizen.
--
Gary''s Student - gsnu200852


"JLR-Mart" wrote:

I have several macros that I run each day, some of which take up to an hour
to complete. Whilst they are running I cannot use Excel. Is there a way to
run macros in the background or, better still, have them run during the night
like a cron job in UNIX ???

Many thanks for any help.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Run macro in background

Here is an idea, but (and this could be the idea killer) it will require you
to lower your security setting for Excel so that it will run macros without
asking permission. If that is acceptable, then using the workbook Open event
code will handle the task...

Private Sub Workbook_Activate()
If Abs(DateDiff("n", "20:00", Time)) < 10 Then
Call Macro1
Call Macro2
Call Macro3
' etc.
Application.DisplayAlerts = False
ThisWorkbook.Save
ThisWorkbook.Close
Application.DisplayAlerts = True
End If
End Sub

First off, change my example time from 20:00 (8:00 PM) to the time you would
like to run your macros at. Second, change the macro names in my three
example Call statements to the macro names you actually want to run (adding
or deleting Call statements as necessary). Third, run Windows Task Scheduler
and set it up to run Excel with your workbook (along with its full path)
specified as the task's Argument... set this task to run at the same time
you changed my example time to at.

--
Rick (MVP - Excel)


"JLR-Mart" wrote in message
...
I have several macros that I run each day, some of which take up to an hour
to complete. Whilst they are running I cannot use Excel. Is there a way to
run macros in the background or, better still, have them run during the
night
like a cron job in UNIX ???

Many thanks for any help.


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro in Background Hager Excel Discussion (Misc queries) 2 January 19th 10 10:17 AM
Run macro in background Andyjim Excel Programming 3 January 25th 08 11:02 PM
How to run a macro in the background & how to end it? 41db14 Excel Programming 1 November 27th 06 02:06 AM
How do I run a macro in the background scrumboss Excel Discussion (Misc queries) 2 April 6th 06 10:50 AM
Run macro in background Yohan Excel Programming 2 February 16th 04 11:38 AM


All times are GMT +1. The time now is 05:58 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"