how can I automatically run a macros nonstop 24 7

sharizan

New Member
Joined
Dec 5, 2007
Messages
1
I have a script named UPDATE written in Modules\Module2 that will automatically copy a DDE value from cell from cell C3 to cell C5 and from cell C3 to cell C6 and so on (until C28) at each hour whenever minute and second are equal to 0 consecutively.

The copying code is functioning well. However, I want this script to be running nonstop 24-7 whenever that excel file is open.

Please help me

:(

the code

________________________________________________________



Dim count As Integer
Sub UPDATE()

' This subroutine processes the turbine data.

Dim data_area, TheDate As String ' Declare variables.

' Initialize range variables
data_area = "C4..O29"

' REPORT RANGE
' REPORT = "A1..N31"

' Set focus to the Daily Log (East Turbine)
Worksheets("EAST TURBINE").Activate
Range("A1").Select


' Copy turbine data into hourly report of the spreadsheet

If Minute(Now()) = 0 Then
' One hour has passed

If Hour(Now()) > 5 Then
'The current time is after 5:00 am
For count = 0 To 17
Range("HOUR_SET").Offset((Hour(Now()) - 6), count).Value = Range("READINGS").Offset(0, count).Value
Next count

Else
'The current time is before 5:00 am
For count = 0 To 17
Range("HOUR_SET").Offset((Hour(Now()) + 18), count).Value = Range("READINGS").Offset(0, count).Value
Next count

End If

If Hour(Now()) = 6 Then
'The beginning of a new day. Print report, save as "today's date.xls" and reset the form to zero.

'To print out the report for East Turbine
Range("REPORT").PrintOut

'To save the file by setting the current date as the filename in excel format
filenm = Format(Date, "MM_dd_YY")
ActiveWorkbook.SaveCopyAs "C:\DAILY_REPORT\" & filenm & ".XLS"

'Clear hourly readings from spreadsheet
Range("C6..O29").Select
Selection.ClearContents

For count = 0 To 17
Range("HOUR_SET").Offset((Hour(Now()) - 6), count).Value = Range("READINGS").Offset(0, count).Value
Next count

End If
End If

End Sub

_____________________________________________________________
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Welcome to the Board!

Take a look at the OnTime method in the VBA helpfile.

You may also want to post the code that you have now.

Hope that helps,

Smitty
 
Upvote 0

Forum statistics

Threads
1,214,651
Messages
6,120,744
Members
448,989
Latest member
mariah3

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