I am very new to VBA and I really appreciate any help! I have a code to saveas every day at 00:10hrs that works great, and I have a code for the cell change, but I don't know how to combine them... It needs to saveas if cell changes, but wait to 00:10hrs, subtract 1 day from the saving date and saveas, since temperature data values belong to previous day. Thank you in advance!
'Cell change is at Sheet2
Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$C$20" Then
Call teste
End If
If Target.Address = "$G$20" Then
Call teste
End If
End Sub
'ThisWorkbook
Private Sub Workbook_Open()
Application.OnTime TimeValue("00:10:00"), "Abre"
End Sub
'Module1
Sub Abre()
Application.OnTime TimeValue("00:10:00"), "Abre"
Dim datestr As String
datestr = Format(Now, "yyyymmdd, hhmm")
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs "D:\Temperature Data\DailyTemp " & datestr & ".xlsm"
End Sub
'Module2
Sub teste()
MsgBox "Did not work"
End Sub