If between the times of.....

ermccarthy

Board Regular
Joined
Feb 15, 2002
Messages
224
I have a workbook that I am having MS Scheduler open every night at 3:00 am, which triggers an auto_open macro that runs.

I want to put some code in the macro that says if it is between 2am and 6am according to my system clock then run macro, if not then the macro ends. This will allow me to enter the workbook during business hours without the macro preforming its duties and uploading various information in it.

Any ideas? Any help would be greatly appreicated!
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Private Sub Workbook_Open()
If Time > #3:00:00 AM# And Time < #6:00:00 AM# Then
MsgBox "this is a test"
End If
End Sub


NOTE::oops:
Another idea would be to open the workbook while calling a particular macro within it , at the same time
example "'Demo.xls'!Hiderows"

The above line opens a workbook called Demo and acitvates it's macro called "hiderows at the same time.

Then you don't have to put your code in the On Open event code :wink:
 
Upvote 0
ermccarthy said:
I have a workbook that I am having MS Scheduler open every night at 3:00 am, which triggers an auto_open macro that runs.

I want to put some code in the macro that says if it is between 2am and 6am according to my system clock then run macro, if not then the macro ends. This will allow me to enter the workbook during business hours without the macro preforming its duties and uploading various information in it.

Any ideas? Any help would be greatly appreicated!
Hi Russell:

How about incorporating something like ...
Code:
if TiMe <#3:00# or Time >#6:00# then exit sub
I hope this helps
 
Upvote 0

Forum statistics

Threads
1,206,815
Messages
6,075,014
Members
446,114
Latest member
FadDak

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top