PC Review


Reply
Thread Tools Rate Thread

Adding names to a cell - application-defined or object-defined error

 
 
Chris
Guest
Posts: n/a
 
      20th Sep 2007
I made my own user defined function to act as a test function for me
to try some stuff out in a sub that is being ran from a button.

My test function is

Function testFunc() As Integer
On Error GoTo errhandler
ActiveWorkbook.Names.Add Name:="ZOMGNAME", RefersTo:="=Sheet1!X20"
testFunc = 1
errhandler:
MsgBox Err.Description
End Function

The error I get is application-defined or object-defined error

The function exists in the workbooks Module1 module

Why am I getting the error?

Thanks in advance

 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      20th Sep 2007
You don't have any cell that contains a formula that tries to use this function,
right?

I couldn't duplicate the error as long as I had a worksheet named Sheet1 in my
activeworkbook.

ps. You may want to avoid the errhandler if there is no error.

Option Explicit
Function testFunc() As Integer
On Error GoTo errhandler
ActiveWorkbook.Names.Add Name:="ZOMGNAME", RefersTo:="=Sheet1!X20"
testFunc = 1
Exit Function
errhandler:
MsgBox Err.Description
End Function

Chris wrote:
>
> I made my own user defined function to act as a test function for me
> to try some stuff out in a sub that is being ran from a button.
>
> My test function is
>
> Function testFunc() As Integer
> On Error GoTo errhandler
> ActiveWorkbook.Names.Add Name:="ZOMGNAME", RefersTo:="=Sheet1!X20"
> testFunc = 1
> errhandler:
> MsgBox Err.Description
> End Function
>
> The error I get is application-defined or object-defined error
>
> The function exists in the workbooks Module1 module
>
> Why am I getting the error?
>
> Thanks in advance


--

Dave Peterson
 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Run-time error '50290': Application-defined or object-defined erro Macro button Microsoft Excel Misc 1 12th Mar 2009 10:59 AM
Application-Defined or object defined error 1004 When ran on exel97 but not 2003 bornweb Microsoft Excel Programming 0 17th Feb 2007 11:30 PM
Copying A Range of Cells From one Sheet to Another - Error Application Defined or Object Defined Matt Microsoft Excel Programming 3 25th Jul 2006 01:13 AM
RE: Runtime error 1004- application defined or object defined erro =?Utf-8?B?Tm92aWNl?= Microsoft Excel Programming 0 6th Feb 2006 09:34 PM
RE: Runtime error 1004- application defined or object defined erro =?Utf-8?B?SmltIFRob21saW5zb24=?= Microsoft Excel Programming 0 6th Feb 2006 09:29 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:52 AM.