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