Execute Formula with VBA Function Upon Saving
我有下面的 VBA 代码来返回单元格中最后保存的时间戳。
该公式仅在我输入公式栏并单击 Enter 时才有效。我希望公式在保存时自动更新。
1 2 3 | Function LastSavedTimeStamp() As Date LastSavedTimeStamp = ActiveWorkbook.BuiltinDocumentProperties("Last Save Time") End Function |
使 UDF 易失性:
1 2 3 4 | Function LastSavedTimeStamp() As Date Application.Volatile LastSavedTimeStamp = ThisWorkbook.BuiltinDocumentProperties("Last Save Time") End Function |
然后在
1 2 3 | Private Sub Workbook_AfterSave(ByVal Success As Boolean) Application.Calculate End Sub |