Forum Discussion

Niclas Johansson's avatar
Niclas Johansson
Brass Contributor
Apr 07, 2018

Formula that's automatic adding date when specific workbook is modified

Hi,  I want as a part of my headers as showed in the attached example file, a cell to show the latest date when someone has made any modifications inside the workbook.   Is there any formula that ...
  • Haytham Amairah's avatar
    Apr 07, 2018

    Hi Niclas,

     

    This question seems easy at first glance!
    But it really cannot be achieved in native Excel, it needs VBA power!

     

    I've updated your workbook with a fairly good solution achieved by VBA which is the Excel scripting language.

     

    The solution is this code:

    Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
    Target.Range("C4") = Now()
    End Sub

    Which is saved in ThisWorkbook code scope.

     

    With this code, each time you save the workbook (which is means that you've made changes to it) this code will trigger and fill the cell C4 with the today's date and time.

     

    Please find the attached file.

     

    Hope that helps

Resources