Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 97
Default Trouble with UDF - getting #NAME error

I created the following UDF in order to show the last saved date:

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
ThisWorkbook.Names.Add Name:="LastSaved", _
RefersToR1C1:="=""" & _
Format(Now, "mmm-dd-yyyy hh:mm") & """"
End Sub

When I enter in a cell =lastsaved or lastsaved() I get the error #NAME. What
am I doing wrong?

Thanks,
Joe M.
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Trouble with UDF - getting #NAME error

Did you put the code under the ThisWorkbook module?

Did you save the workbook at least onced so the event would fire and the name
would be created?

Did you ever have a function/name/module name called "LastSaved" in the
troublesome workbook?

Since you're refering to a name, you don't want the () in your formula.

Just use:
=LastSaved



Joe M. wrote:

I created the following UDF in order to show the last saved date:

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
ThisWorkbook.Names.Add Name:="LastSaved", _
RefersToR1C1:="=""" & _
Format(Now, "mmm-dd-yyyy hh:mm") & """"
End Sub

When I enter in a cell =lastsaved or lastsaved() I get the error #NAME. What
am I doing wrong?

Thanks,
Joe M.


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
IRR Trouble jeff Excel Worksheet Functions 1 August 20th 07 09:42 PM
Trouble with IF EG Excel Worksheet Functions 9 October 3rd 06 07:15 PM
UDF trouble Ray A Excel Discussion (Misc queries) 1 September 8th 05 09:23 PM
more trouble with i Ralphael1 New Users to Excel 9 July 24th 05 02:55 AM
Trouble shooting#NA error in Array formula RonR Excel Discussion (Misc queries) 2 June 14th 05 09:58 PM


All times are GMT +1. The time now is 02:28 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"