Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8054005
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T08:02:19+00:00 2026-06-05T08:02:19+00:00

Is there a way to make an open worksheet close itself if there is

  • 0

Is there a way to make an open worksheet close itself if there is no activity on it for more than 5 minutes?

So for example: I work on a worksheet for a while then walk away for 20 minutes with said sheet open. Someone on the network requires to access the sheet but can’t because I’m on it.

I want it so that after me being away from my desk for more than 5 minutes the sheet will save itself and close out said sheet.

Is this possible? If so how? I can find scripts to show how to save and close a sheet, but I’ve yet to find one that uses a timer…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T08:02:21+00:00Added an answer on June 5, 2026 at 8:02 am

    Ok, with the original answer below, I came up with my own, after a little more research.

    Once you open the developer’s section you will find your sheets, place this code below into ThisWorkbook. That will allow your code to work through the entire sheet. I now it set up where there is a 10:00 minute initial timer, and a 05:00 minute timer if there is activity after the fact. You can change that to whatever you want.

    Option Explicit
    Private Sub Workbook_Open()
        EndTime = Now + TimeValue("00:10:00")
        RunTime
    End Sub
    
    Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
        If EndTime Then
            Application.OnTime _
                    EarliestTime:=EndTime, _
                    Procedure:="CloseWB", _
                    Schedule:=False
            EndTime = Empty
        End If
        EndTime = Now + TimeValue("00:05:00")
        RunTime
    End Sub
    

    The part below this needs to go into a newly created module, name it whatever you want, mine is called SaveWB

    Option Explicit
    
    Public EndTime
    Sub RunTime()
        Application.OnTime _
                EarliestTime:=EndTime, _
                Procedure:="CloseWB", _
                Schedule:=True
    End Sub
    
    Sub CloseWB()
        Application.DisplayAlerts = False
        With ThisWorkbook
            ThisWorkbook.Close savechanges:=True
        End With
    End Sub
    

    I changed the code from:

    With ThisWorkbook
        .Save
        .Saved = True
        .Close
    End With
    

    To what was above it.

        With ThisWorkbook
            ThisWorkbook.Close savechanges:=True
        End With
    

    The part I created works, the part that was originally posted works in closing but not saving. Do what you will with it, change it as you deem fit, but I am glad I got it working.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a way to make this code work? LogonControl.java @Audit(AuditType.LOGON) public void login(String
Is there any way to make a DataTemplate reference itself just from XAML? In
Is there a way to make a toolbar button look different than the rest
is there a way how to make Matlab open excel files directly in MS
Is there a way to make the Developer Tools window open Maximized automatically again?
In PHP (v5), is there a way to make multiple requests on an open
is there a way to make my code run smoother and more efficient? var
Is there a way to make files opened for editing in the terminal open
Is there a way to make, that after any swf changes, site would open
Is there a way to make a click-to-edit control in silverlight? I've got some

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.