Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default User Defined Function giving #NAME? error

Well - I had a brainstorm last night - this morning I tried it...
I made a fresh excel workbook, and put in my function - and it worked like a
charm!! So I guess I'm just going to copy & paste as best as I can and just
scrap the old workbook. But thank so much for your informative posts, I have
learned a lot with this : )

"Jim Thomlinson" wrote:

So you are trying to use the function defined in one workbook in another
workbook? In the functions list just select the function and it should walk
you through adding the function to your workbook. Here is a little info on
Functions. Functions Return values as opposed to Subs which perform actions.
Functions can take arguments. When you pass in an argument you should specify
exactly what data type the argument is. Additionally since functions return
values you should specify what is being returned. If you don't speicify then
the function assumes Variant data type. So what you have is essentially

Public Function Comission(ByRef MyNum as Variant) as Variant
Comission = MyNum * 0.6
End Function

Variants are inefficient so you are better off to specify the data types.
Additionally you should specify Pass by Value or Pass by Reference. I leave
that to you to investigate. Your function should be...

Public Function Commission(ByVal MyNum as range) as Double
ComMission = MyNum.Value * 0.6
End Function
--
HTH...

Jim Thomlinson


"I need help please" wrote:

Thanks Jim,
I tried that - it found my function, but it was called
='Study Information.Testing.xls'!Module1.Comission()
and said that it did not take any parameters! And then it still gave me the
#NAME? error!

I can't spell to save my life, so I will copy paste the function again

Public Function Comission(MyNum)
Comission = MyNum * 0.6
End Function

It is stored in: Module 1 (here's what it looks like in VB Editor)
VBAProject(StudyInformation.testing.xls)
+ Microsoft Excel Objects
- Modules
|_ Module1

So, it knows I have the function, but I bet its somehow in the wrong place
or something. But, it said no parameters / arguments - and clearly I have
1...

"Jim Thomlinson" wrote:

What you have should work. Everything that is being suggested will make the
function potentailly more efficient or such but what you have is technically
correct. Here is something to check. If you selet Insert - Function from the
menu and then specify "User Defined" under "or select a Category" does your
function show up??? It should.
--
HTH...

Jim Thomlinson


"I need help please" wrote:

Sorry - that was a typo in the post - I used copy & paste for this one!

Public Function Comission(MyNum)
Comission = MyNum * 0.6
End Function

and the (MyNum As WHAT) didn't seem to work either

"I need help please" wrote:

I had a previous post with a few questions. Most of them were answered.
But, I'm still having trouble.

Here's what I have in detail:

In 'Module1'

Public Fuction Comission(MyNum)
Comission = MyNum * 0.6
End Function

(I then hit save, exit VBE, save workbook)
types in =comission(A1)

I get #NAME? error still...

Thanks in advance for your help.

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
ASSIGNING THE VALUE TO A NAMED RANGE GIVING OBJECT DEFINED ERROR CAPTGNVR Excel Programming 8 February 16th 07 05:13 PM
Excel - User Defined Function Error: This function takes no argume BruceInCalgary Excel Programming 3 August 23rd 06 08:53 PM
Error messages from user defined Excel worksheet function Tom Ogilvy Excel Programming 3 March 18th 06 04:30 PM
#Name? Error in User Defined VB Function idgity Excel Worksheet Functions 2 August 30th 05 08:58 PM
User-defined data type; Error: Only User-defined types... tiger_PRM Excel Programming 1 July 18th 04 03:32 PM


All times are GMT +1. The time now is 02:54 PM.

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

About Us

"It's about Microsoft Excel"