CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 11 of 11

Threaded View

  1. #1
    Join Date
    Mar 2020
    Posts
    5

    need help to understand code

    hello guys i am wondering if any of you could explain what this code do and how it works.
    Code:
    Private Sub Workbook_Open()
        lastSelectionChange = Now
        closeWB
    End Sub
    
    Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
        lastSelectionChange = Now
        'MsgBox (Now)
    End Sub
    Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
        lastSelectionChange = Now
        'MsgBox (Now)
    End Sub
    
    
    Module 1 
    Public lastSelectionChange As Date
    
    
    Sub closeWB() // sluit workbook
        If DateDiff("n", lastSelectionChange, Now) > 5 Then
            ThisWorkbook.Close SaveChanges:=True
        Else
            Application.OnTime Now + TimeSerial(0, 1, 0), "closeWb"
        End If
    End Sub
    I am kinda new and wonder how this works . like what is a function or what value's do they have.

    Kind regards
    Last edited by VictorN; March 19th, 2020 at 03:07 AM. Reason: added CODE tags

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured