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
_____________________________________________________________
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
_____________________________________________________________