Computing.Net > Forums > Office Software > User Defined Funct prob Excel 2000

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Click here to start participating now! Also, check out the New User Guide.

User Defined Funct prob Excel 2000

Reply to Message Icon

Name: Langrto
Date: February 16, 2005 at 12:20:26 Pacific
OS: Office 2000/Win ME
CPU/Ram: MX 200/256 MB
Comment:

I created a UDF to put the "date last saved" in a cell in my spread sheet, as follows:

Function DateLastSaved(property as string)

DateLastSaved = ActiveWorkbook.BuiltinDocumentProperties(property)

End Function

I then set the formula, 'DateLastSaved=("Last Save Time")' in the cell inwhich I want the date to appear. It appeared to work fine, once (when I entered it).

The function only seems to work when I enter it in the cell. I save my file, changed the system date, re-opened the spread sheet and it contained the correct date. I altered a cell and save the file again. The date didn't change in the "date last saved" cell. I closed the spreadsheet and re-opened it. Again the date did not change. I selected the cell and re-rentered the function - the date changed. I must be missing something in my function? Can anyone tell me what I'm missing?

Thanks,
Tom



Sponsored Link
Ads by Google

Response Number 1
Name: A Certain TH
Date: February 18, 2005 at 06:45:03 Pacific
Reply:

Stuff like this is a bit awkward, because xl doesn't know which properties you have in a UDF (since you could potentially have infinite ones) and so it doesn't assume it needs to recalculate them.

This is sensible, because if you send the sheet to someone who doesn't have the function (say its an add-in) then they don't automatically lose all UDF data.


The simplest solution to the problem this is causing you is to force it to re-input your cell value as you save it. (Either with or without a UDF)

Insert a module and use a macro like this:

Private Sub Workbook_BeforeClose(varX As Boolean)
Sheets("SheetName").Range("A1") = "=FormulaHere"
End Sub

and either use the FormulaHere part to enter your UDF formula, or just to insert the current time/date.


Hope that helps
Tom


0

Response Number 2
Name: Langrto
Date: February 19, 2005 at 14:02:42 Pacific
Reply:

Tom, Thanks for your thoughts. Wouldn't you solution change the date every time the spreadsheet was closed? I don't want that to happen. I only want to change that date when the file is saved. The spread sheet is used to calculate customer estimates, so, is often opened to look at data only. The client wishes the date to be the last time it was modified and save.

Thanks for your time,
Tom


0

Response Number 3
Name: A Certain TH
Date: March 2, 2005 at 01:14:08 Pacific
Reply:

I'm not sure that the net effect is any different - but I guess its probably safer to use this:


Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Sheets("Sheet1").Range("A1") = Now
End Sub


Make sure that you put the code in the workbook module. It won't work anywhere else.

Cheers
Tom


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


Retrieving text box behin... Excel 2000 Errors



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Office Software Forum Home


Sponsored links

Ads by Google


Results for: User Defined Funct prob Excel 2000

Excel 2000 www.computing.net/answers/office/excel-2000/4443.html

Excel 2000 Auto Calc www.computing.net/answers/office/excel-2000-auto-calc/401.html

excel 2000 - www.computing.net/answers/office/excel-2000-/2794.html