Sean15
Well-known Member
- Joined
- Jun 25, 2005
- Messages
- 722
- Office Version
- 2010
- Platform
- Windows
This macro is intended to close the worksheet after 2 minutes of inactivity. However, I’ve observed that when I copy only data or text to paste into another worksheet (as shown in Figure 1), the macro doesn’t close the worksheet after the 2 minutes of inactivity. On the other hand, if I copy the entire cell (see Figure 2), the macro functions as expected and closes the worksheet after 2 minutes. Could you please update the macro so that it will close the worksheet regardless of whether I copy just the text or the entire cell? Thank you.
Sean
Sean
VBA Code:
Dim CloseTime As Date
Sub TimeSetting()
Workbooks("PW 065852").Activate
Application.CutCopyMode = False
CloseTime = Now + TimeValue("00:02:00")
On Error Resume Next
Application.OnTime EarliestTime:=CloseTime, _
Procedure:="SavedAndClose", Schedule:=True
End Sub
Sub TimeStop()
On Error Resume Next
Application.OnTime EarliestTime:=CloseTime, _
Procedure:="SavedAndClose", Schedule:=False
End Sub
Sub SavedAndClose()
ThisWorkbook.Close Savechanges:=True
End Sub