Recalculate cell with UDF

N

Numfric

I have a cell with the following contents:
=CONCATENATE("Last updated ",TEXT(LastSaved(), "mmmm dd, yyyy"))

LastSaved is a UDF with the following definition:

Public Function LastSaved()
LastSaved = ActiveWorkbook.BuiltinDocumentProperties("Last Save Time")
End Function

I have automatic recalc turned on. If I save the workbook, exit and bring
it up again, the cell value still shows the previous last saved date. If I
F2 on the cell and press Enter, the date is refreshed with the current date.
What's going on?
 
A

Arvi Laanemets

Hi

Try this:
=IF(NOW()>0,"Last updated " & TEXT(LastSaved(), "mmmm dd, yyyy"))

Arvi Laanemets
 
O

Oliver Ferns via OfficeKB.com

Try putting

Application.Volatile True

In your UDF.

Hth,
Oli
 
N

Numfric

Thank you both for your responses. Both methods work. I went with
Application.Volatile (True is implied), as there is less clutter in the cell.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top