A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Excel » Worksheet Functions
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

User Defined Functions



 
 
Thread Tools Display Modes
  #1  
Old December 21st, 2006, 09:21 PM posted to microsoft.public.excel.worksheet.functions
CH
external usenet poster
 
Posts: 54
Default User Defined Functions

I occasionally mke user-defined functions in VBA. I am trying to write a
function using the LOG10() function and the FIXED() function and I get an
error for both of these functions - - unlike when I use other canned
functions. Are there limitations to the functions I can use in a
user-defined function? LOG() works, so I can work around the LOG10()
function.
  #2  
Old December 21st, 2006, 10:01 PM posted to microsoft.public.excel.worksheet.functions
JLatham
external usenet poster
 
Posts: 3,017
Default User Defined Functions

If you're trying to use the LOG10() function inside of a VBA module, well,
there ain't no such animal.

Static Function Log10(X)
Log10 = Log(X) / Log(10#)
End Function

There's some workaround code that will give you LOG10() using Log() (which
is available in VBA).
Similarly, there is no FIXED() in VBA - that's also a worksheet only
function. Closest thing in VBA is probably FIX(n) where n is a number, and
FIX(n) returns the integer portion of n.


"CH" wrote:

I occasionally mke user-defined functions in VBA. I am trying to write a
function using the LOG10() function and the FIXED() function and I get an
error for both of these functions - - unlike when I use other canned
functions. Are there limitations to the functions I can use in a
user-defined function? LOG() works, so I can work around the LOG10()
function.

  #3  
Old December 21st, 2006, 10:03 PM posted to microsoft.public.excel.worksheet.functions
Niek Otten
external usenet poster
 
Posts: 2,533
Default User Defined Functions

LOG10 and FIXED are not VBA functions. Use Application.Worksheetfunction.LOG10 if you have to.

--
Kind regards,

Niek Otten
Microsoft MVP - Excel

"CH" wrote in message ...
|I occasionally mke user-defined functions in VBA. I am trying to write a
| function using the LOG10() function and the FIXED() function and I get an
| error for both of these functions - - unlike when I use other canned
| functions. Are there limitations to the functions I can use in a
| user-defined function? LOG() works, so I can work around the LOG10()
| function.


  #4  
Old December 21st, 2006, 10:13 PM posted to microsoft.public.excel.worksheet.functions
Dana DeLouis
external usenet poster
 
Posts: 468
Default User Defined Functions

...using the LOG10() function and the FIXED() function and I get an
error for both of these functions


Sub Demo()
Debug.Print WorksheetFunction.Log10(100)
Debug.Print WorksheetFunction.Fixed(1 / 7, 2)
' or...
With WorksheetFunction
Debug.Print .Log10(100)
Debug.Print .Fixed(1 / 7, 2)
End With
End Sub

--
HTH :)
Dana DeLouis
Windows XP & Office 2003


"CH" wrote in message
...
I occasionally mke user-defined functions in VBA. I am trying to write a
function using the LOG10() function and the FIXED() function and I get an
error for both of these functions - - unlike when I use other canned
functions. Are there limitations to the functions I can use in a
user-defined function? LOG() works, so I can work around the LOG10()
function.



  #5  
Old September 22nd, 2008, 10:16 AM posted to microsoft.public.excel.worksheet.functions
James.Z
external usenet poster
 
Posts: 1
Default User Defined Functions

please see Neik's answer. You need write the full path reference when you use
worksheetfunction. Obviously, You lost key word "Application." before
"WorksheetFunction.Log10(100)"

"Dana DeLouis" wrote:

...using the LOG10() function and the FIXED() function and I get an
error for both of these functions


Sub Demo()
Debug.Print WorksheetFunction.Log10(100)
Debug.Print WorksheetFunction.Fixed(1 / 7, 2)
' or...
With WorksheetFunction
Debug.Print .Log10(100)
Debug.Print .Fixed(1 / 7, 2)
End With
End Sub

--
HTH :)
Dana DeLouis
Windows XP & Office 2003


"CH" wrote in message
...
I occasionally mke user-defined functions in VBA. I am trying to write a
function using the LOG10() function and the FIXED() function and I get an
error for both of these functions - - unlike when I use other canned
functions. Are there limitations to the functions I can use in a
user-defined function? LOG() works, so I can work around the LOG10()
function.




 




Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 09:14 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.