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. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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 | |
|
|