Reputation: 139
I have Excel formula macro that display last saved file time
Function LastModified() As Date
LastModified = ActiveWorkbook.BuiltinDocumentProperties("Last Save Time")
End Function
In cell B5 I call it out in a following format
=LastModified()
It returns the following data: "43070.58675" which I convert using Format Cell option to a date and time format "01/12/2017 12:38"
However I would like to add a text "Last modified: " before this function in the same cell B5.
Please help, thanks
Upvotes: 0
Views: 713
Reputation: 21629
If other cells use B5
in formulas, you can retain the DateTime data type and add a title with a custom number format:
Right Click →
Format Cells...
→Number
tab →Custom
Type:
"Last Modified: "h:mm AM/PM
If you want to change the original formula so that it will always return Last modified: 01/12/2017 12:38
(as text) then it's as simple as:
Function LastModified() As String
LastModified = "Last Modified: " & ActiveWorkbook.BuiltinDocumentProperties("Last Save Time")
End Function
Upvotes: 2
Reputation: 3801
You should be able to use the Text
function to format it like so:
="Last Modified " & TEXT(LastModified(), "dd/mm/yyyy hh:mm")
Upvotes: 3