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

I am trying to create a customized function.When ever I use cosh or sinh or
ln .. function within a formula I get a compile error. Sub or function not
defined.

sample code

Function tg(number)
tg = Cosh(number) + Sin(number)
End Function

I get no error when I use this code but with simple sin and cos

Function tg(number)
tg = Cos(number) + Sin(number)
End function

any ideas why this happens ?

Thanks in advance

ravi


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default customized function

cos and sin are legitimate functions in VBA (as well as Excel worksheet
functions - but used as you do, you are using the VBA versions). This is
not true of Cosh, Sinh or Ln. You can use

Worksheetfunction.Cosh, WorksheetFunction.Sinh and WorksheetFunction.Ln.

There is actually a function Log in VBA that is the same as the Excel
Worksheet function Ln. So you could use Log instead of LN.

--
Regards,
Tom Ogilvy

"ravi" wrote in message
...
I am trying to create a customized function.When ever I use cosh or sinh

or
ln .. function within a formula I get a compile error. Sub or function

not
defined.

sample code

Function tg(number)
tg = Cosh(number) + Sin(number)
End Function

I get no error when I use this code but with simple sin and cos

Function tg(number)
tg = Cos(number) + Sin(number)
End function

any ideas why this happens ?

Thanks in advance

ravi




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default customized function

Try this:

Function tg(number)
tg = Excel.WorksheetFunction.Cosh(number) + Sin(number)
End Function


That worked for me. The runtime did not know where to find the Cosh
function.

Thanks,
Chuck
ravi wrote:
I am trying to create a customized function.When ever I use cosh or sinh or
ln .. function within a formula I get a compile error. Sub or function not
defined.

sample code

Function tg(number)
tg = Cosh(number) + Sin(number)
End Function

I get no error when I use this code but with simple sin and cos

Function tg(number)
tg = Cos(number) + Sin(number)
End function

any ideas why this happens ?

Thanks in advance

ravi


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
SOS! how do I write a customized function to do multiple-value lookupin Excel 2007? LunaMoon Excel Discussion (Misc queries) 1 December 1st 09 04:40 AM
SOS! how do I write a customized function to do multiple-value lookupin Excel 2007? LunaMoon Charts and Charting in Excel 0 December 1st 09 03:37 AM
Formula Function INTO Customized Toolbar 23hitman Excel Discussion (Misc queries) 1 August 22nd 09 11:41 PM
Customized Formula Learning Excel Excel Discussion (Misc queries) 7 February 17th 08 11:51 PM
Customized function (in cell) does not refresh value :o( MarcL Excel Discussion (Misc queries) 3 February 28th 06 09:57 PM


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