View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
K Dales[_2_] K Dales[_2_] is offline
external usenet poster
 
Posts: 1,163
Default USING LOG and LN

Different definitions: VBA and Excel functions are not always equivalent

From VB help file:
Log(number)

The required number argument is a Double or any valid numeric expression
greater than zero.

Remarks

The natural logarithm is the logarithm to the base e. The constant e is
approximately 2.718282.

You can calculate base-n logarithms for any number x by dividing the natural
logarithm of x by the natural logarithm of n as follows:

Logn(x) = Log(x) / Log(n)

The following example illustrates a custom Function that calculates base-10
logarithms:

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

From Excel help:

LOG
See Also

Returns the logarithm of a number to the base you specify.

Syntax

LOG(number,base)

Number is the positive real number for which you want the logarithm.

Base is the base of the logarithm. If base is omitted, it is assumed to be
10.



--
- K Dales


"ravi" wrote:

Hello:

When I use this line in piece of code

targetRange(x) = Log(sourceRange(i) * 10)

The target range contains the natural log or ln value

When I use this line in a piece of code

Range("C1:C3").Formula = "=LOG(A1*10)"

The range log to base 10 or log value.

Why is that?

How do I get log to base 10 using the first line ?

Thanks

Ravi