![]() |
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 |
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 |
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 |
All times are GMT +1. The time now is 07:18 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com