I have VBA code that is calling this method after a certain amount of time has passed using application.ontime,
Sub run()
Worksheets("Sheet1").Calculate
Cells(2, 5).Value = Cells(2, 5).Value + 1
ActiveWorkbook.Save
End Sub
however, after the ActiveWorkbook.Save line, the macros just stop running. how can i continue to run my macros after saving the workbook, or maybe call a macro upon saving? I'm using excel 2013 btw
here is my macro that calls run:
Sub every30seconds()
runTime = Now + TimeValue("00:00:30")
Application.OnTime EarliestTime:=runTime, Procedure:="run", schedule:=True
If Cells(2, 5).Value = 2 Then
Application.OnTime runTime, "run", , False
Cells(2, 5).Value = Cells(2, 5).Value - 2
End If
End Sub
Workbook_AfterSave
orWorkbook_BeforeSave
– dbmitchrunTime = Now + TimeValue("00:00:30") Application.OnTime EarliestTime:=runTime, Procedure:="run", schedule:=True
– dbmitch