#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 355
Default One A day

Hello Group
What should I add to my code to prevent it from being run once a day? Once
updated yesterdays date is in A2 of sheet1.
Thanks!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default One A day

if worksheets("Sheet1").Range("A2").Value = Date - 1 then exit sub

--
Regards,
Tom Ogilvy


"Sandy" wrote in message
...
Hello Group
What should I add to my code to prevent it from being run once a day?

Once
updated yesterdays date is in A2 of sheet1.
Thanks!



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,163
Default One A day

Do you mean "prevent it from being run more than once a day?" Test the value
before the code changes it:
Sub RunMeOnceADay()
If Worksheeets("Sheet1").Range("A2").Value < Date()-1 Then
... code to run goes here
Worksheeets("Sheet1").Range("A2").Value = Date()-1 ' sets the date
in A2
End If
End Sub
If you really mean "once a day", when do you actually want/need the code to
run?
--
- K Dales


"Sandy" wrote:

Hello Group
What should I add to my code to prevent it from being run once a day? Once
updated yesterdays date is in A2 of sheet1.
Thanks!

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 355
Default One A day

Thanks for the reply
The code is run manually, but we are having trouble with some operators
running it twice. As I said when the macro runs it changes the date in A2 to
yesterdays date and that is the check I was thinking of using to determine if
it had been already run. I guess a message box would be good too so I can
point out the error to the operator.
Thanks!

"K Dales" wrote:

Do you mean "prevent it from being run more than once a day?" Test the value
before the code changes it:
Sub RunMeOnceADay()
If Worksheeets("Sheet1").Range("A2").Value < Date()-1 Then
... code to run goes here
Worksheeets("Sheet1").Range("A2").Value = Date()-1 ' sets the date
in A2
End If
End Sub
If you really mean "once a day", when do you actually want/need the code to
run?
--
- K Dales


"Sandy" wrote:

Hello Group
What should I add to my code to prevent it from being run once a day? Once
updated yesterdays date is in A2 of sheet1.
Thanks!

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



All times are GMT +1. The time now is 12:49 AM.

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

About Us

"It's about Microsoft Excel"