#1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 96
Default AutoRun Macro

I have the following macro for my spreadsheet along with one cell designated
for the Taday() function. How do I set this macro to autorun when the date
changes?

Sub CustomerFutures()
'
' CustomerFutures Macro
'
'
Range("H9:I31").Select
Selection.Copy
Range("D9:E31").Select
ActiveSheet.Paste
Range("F9:I31").Select
Application.CutCopyMode = False
Selection.ClearContents
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 10,124
Default AutoRun Macro

This should do it. Now you need to tell us when you want it to fire. If you
want it to fire when the file opened put in the ThisWorkbook module
Auto_Open. But that would assume the changes had been made. Perhaps you want
to put in the Before_close.

Sub runifdatechg()
If Range("c1") < Date Then
Range("H9:I31").Copy Range("D9:E31")
Range("F9:I31").ClearContents
Range("c1") = Date
End If
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"chrisnsmith" wrote in message
...
I have the following macro for my spreadsheet along with one cell
designated
for the Taday() function. How do I set this macro to autorun when the
date
changes?

Sub CustomerFutures()
'
' CustomerFutures Macro
'
'
Range("H9:I31").Select
Selection.Copy
Range("D9:E31").Select
ActiveSheet.Paste
Range("F9:I31").Select
Application.CutCopyMode = False
Selection.ClearContents
End Sub


  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 96
Default AutoRun Macro

I'm new at Excel so please bare with me. I simply want the macro to run when
the date in cell K2 changes and at no other time. Can this be done without
actually being in the Excel program, in other words, overnight while the
computer is idle?

"Don Guillett" wrote:

This should do it. Now you need to tell us when you want it to fire. If you
want it to fire when the file opened put in the ThisWorkbook module
Auto_Open. But that would assume the changes had been made. Perhaps you want
to put in the Before_close.

Sub runifdatechg()
If Range("c1") < Date Then
Range("H9:I31").Copy Range("D9:E31")
Range("F9:I31").ClearContents
Range("c1") = Date
End If
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"chrisnsmith" wrote in message
...
I have the following macro for my spreadsheet along with one cell
designated
for the Taday() function. How do I set this macro to autorun when the
date
changes?

Sub CustomerFutures()
'
' CustomerFutures Macro
'
'
Range("H9:I31").Select
Selection.Copy
Range("D9:E31").Select
ActiveSheet.Paste
Range("F9:I31").Select
Application.CutCopyMode = False
Selection.ClearContents
End Sub



  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3,346
Default AutoRun Macro

Hi,

In the ThisWorkbook object you could consider something like this

Private Sub Workbook_Open()
Application.OnTime TimeValue("00:00:00"), "my_Procedure"
End Sub

This is your code in a regular module.

Public Sub my_Procedure()
you code
End Sub

However, Excel must be running for this to trigger at the desired time. A
computer that is in sleep mode will not run the procedure at the desired
time. If you then wake the computer up I don't know if it will automatically
run past stuff or not, you will need to check that.

--
If this helps, please click the Yes button

Cheers,
Shane Devenshire


"chrisnsmith" wrote:

I'm new at Excel so please bare with me. I simply want the macro to run when
the date in cell K2 changes and at no other time. Can this be done without
actually being in the Excel program, in other words, overnight while the
computer is idle?

"Don Guillett" wrote:

This should do it. Now you need to tell us when you want it to fire. If you
want it to fire when the file opened put in the ThisWorkbook module
Auto_Open. But that would assume the changes had been made. Perhaps you want
to put in the Before_close.

Sub runifdatechg()
If Range("c1") < Date Then
Range("H9:I31").Copy Range("D9:E31")
Range("F9:I31").ClearContents
Range("c1") = Date
End If
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"chrisnsmith" wrote in message
...
I have the following macro for my spreadsheet along with one cell
designated
for the Taday() function. How do I set this macro to autorun when the
date
changes?

Sub CustomerFutures()
'
' CustomerFutures Macro
'
'
Range("H9:I31").Select
Selection.Copy
Range("D9:E31").Select
ActiveSheet.Paste
Range("F9:I31").Select
Application.CutCopyMode = False
Selection.ClearContents
End Sub



  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 96
Default AutoRun Macro

As I said before, I'm new at this so it took me awhile to realized your code
would only run on the initial opening of my workbook. I inserted it in a
module and it worked great. Thanks.

"Don Guillett" wrote:

This should do it. Now you need to tell us when you want it to fire. If you
want it to fire when the file opened put in the ThisWorkbook module
Auto_Open. But that would assume the changes had been made. Perhaps you want
to put in the Before_close.

Sub runifdatechg()
If Range("c1") < Date Then
Range("H9:I31").Copy Range("D9:E31")
Range("F9:I31").ClearContents
Range("c1") = Date
End If
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"chrisnsmith" wrote in message
...
I have the following macro for my spreadsheet along with one cell
designated
for the Taday() function. How do I set this macro to autorun when the
date
changes?

Sub CustomerFutures()
'
' CustomerFutures Macro
'
'
Range("H9:I31").Select
Selection.Copy
Range("D9:E31").Select
ActiveSheet.Paste
Range("F9:I31").Select
Application.CutCopyMode = False
Selection.ClearContents
End Sub





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
autorun a macro [email protected] New Users to Excel 2 January 24th 08 05:41 PM
Autorun Macro rexmann Excel Discussion (Misc queries) 2 August 2nd 06 02:03 PM
Autorun macro Kelly Excel Worksheet Functions 1 January 18th 06 04:03 PM
MACRO AUTORUN b52shut Excel Discussion (Misc queries) 1 December 15th 05 08:48 AM
Autorun macro by date Steve Excel Discussion (Misc queries) 2 May 3rd 05 09:09 AM


All times are GMT +1. The time now is 08:55 AM.

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"