Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default writing its own function

In Excel 2000 (which I use), neither sign nor erf is supported in VBA (and
erf is not even listed as a worksheet function). (see VBA help: functions)

Bob L.


"AG" wrote in message ...
And I am using a Module, not a class module.



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default writing its own function

Hi all,

I am writing this function to be used in a sheet :

Function my_erf(x)
If (Abs(x) 27) Then
my_erf = 1
Else
my_erf = sign(x)*erf(abs(x))
End If
End Function


I put it inside a modul. I have two moduls : one for my macros, and one
for this function.

When I try to use the function, I get the message that the sign()
function is unknown, and the same for the erf() function, which I can
both use in my sheet.

I don't understand why, and how I can solve this.

Thanks,

Alexandre.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default writing its own function

And I am using a Module, not a class module.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 77
Default writing its own function

Not sure, but if 'x' were -2, is this what you are trying to do?

Sub Demo()
Dim v
v = Sgn(-2) * [Erf(Abs(-2))]
End Sub

Note that in VBA, the "Sign" function is called "Sgn" (Worksheet, it is
'Sign')

HTH
--
Dana DeLouis
Using Windows XP & Office XP
= = = = = = = = = = = = = = = = =


"Bob L." wrote in message
...
In Excel 2000 (which I use), neither sign nor erf is supported in VBA (and
erf is not even listed as a worksheet function). (see VBA help:

functions)

Bob L.


"AG" wrote in message ...
And I am using a Module, not a class module.



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 77
Default writing its own function

Just a note. I believe the Erf function is 1 for numbers just short of 6 at
full machine precision.
You may want to consider:
If (Abs(x) =6 Then my_erf = 1

If (Abs(x) 27) Then
my_erf = 1


--
Dana DeLouis
Using Windows XP & Office XP
= = = = = = = = = = = = = = = = =


"Dana DeLouis" wrote in message
...
Not sure, but if 'x' were -2, is this what you are trying to do?

Sub Demo()
Dim v
v = Sgn(-2) * [Erf(Abs(-2))]
End Sub

Note that in VBA, the "Sign" function is called "Sgn" (Worksheet, it is
'Sign')

HTH
--
Dana DeLouis
Using Windows XP & Office XP
= = = = = = = = = = = = = = = = =






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default writing its own function

Dana DeLouis wrote:
Not sure, but if 'x' were -2, is this what you are trying to do?

Sub Demo()
Dim v
v = Sgn(-2) * [Erf(Abs(-2))]
End Sub

Note that in VBA, the "Sign" function is called "Sgn" (Worksheet, it is
'Sign')

HTH


Thanks Dana, using Sgn() instead of sign() works fine. But I still get a
#NOM? error.

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default writing its own function

Dana DeLouis wrote:
Just a note. I believe the Erf function is 1 for numbers just short of 6 at
full machine precision.
You may want to consider:
If (Abs(x) =6 Then my_erf = 1


yes, eventually.

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default writing its own function

Dana DeLouis wrote:
Not sure, but if 'x' were -2, is this what you are trying to do?

yes



Sub Demo()
Dim v
v = Sgn(-2) * [Erf(Abs(-2))]
End Sub


why do you use [.] and not simply (.)

v=Sgn(-2) * Erf(Abs(-2)) ?

  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 77
Default writing its own function

Hi AG. Yes, my mistake. I was using [] because I did not have a vba
library reference set to "atpvbaen.xls".
I see that you probably have that reference set, so the [] are not required.
:)
Without the reference set, you would get a "sub or function not defined"
error.

--
Dana DeLouis
Using Windows XP & Office XP
= = = = = = = = = = = = = = = = =


"AG" wrote in message ...
Dana DeLouis wrote:
Not sure, but if 'x' were -2, is this what you are trying to do?

yes

Sub Demo()
Dim v
v = Sgn(-2) * [Erf(Abs(-2))]
End Sub


why do you use [.] and not simply (.)

v=Sgn(-2) * Erf(Abs(-2)) ?



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
need help writing function LQQKB4uleep Excel Worksheet Functions 9 November 20th 09 12:30 AM
Need Help With Writing Concatenate Function Michael Styles[_2_] Excel Worksheet Functions 5 August 15th 09 05:20 PM
Function writing help Gator Excel Worksheet Functions 2 March 2nd 09 05:51 PM
WRITING A WHAT IF FUNCTION MARY Excel Worksheet Functions 1 June 13th 08 12:36 PM
Help Writing Function JamesEXCELhelp Excel Worksheet Functions 8 January 4th 08 06:06 AM


All times are GMT +1. The time now is 10:13 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"