Replace Worksheetfunction.ln code

M

michelle439731

Morning,

I want to replace the code "worksheetfunction.ln" with "math.log" in my code.
Is this the same calculation? If not what piece of code should I be using.

Thank you very much for your help,

Michelle
 
J

joel

The math constand "e" is approximately 2.3. To get the exact value yo
use the ln(1).

Ln and log are equivalent functions that give different results becaus
the base is different. Ln the base is the constand "e", while log bas
is usually 10 but can be others bases.


There are 3 functions in excel
LN(Number), LOG(Number,Base), LOG10(Number)

LOG10(Number) = LOG(Number,10)
LN(Number) = LOG(Number,LN(1))
 
R

Rick Rothstein

Yes, VB's built-in Log function is the same as the worksheet's LN
function... they are both what is known as the "Natural Log" function
(logarithm to the base e). I think the reason for the different names is
that VB's Log function is the only one provided (VB is based on the BASIC's
of old where I'm guessing the name for the function was chosen because it is
spelled the way it sounds) whereas the worksheet provides two logarithm
functions, LN and LOG... where LOG defaults to base 10 (LOG is the normal
way mathematicians/statisticians spell the "logarithm to the base 10") and,
as discussed, LN is the "logarithm to base e" which is spelled LN in
mathematical circles. So, VB used a name created decades ago for its only
logarithm function in order to (I'm guessing) make it easy to remember
within a language developed to make programming easier to learn overall,
while it appears Excel chose to use the more normally accepted spellings for
its two "logarithm functions.

I did want to point out that you do not need to proceed VB's Log function
with its library name (Math)... that is the default, so you can just use
Log(YourNumber) in your code.
 
M

michelle439731

Superb, that is exactly what I wanted to know.

And a history lesson too.

Thank you very much,

Michelle
 
Top