Replace Worksheetfunction.ln code

  • Thread starter Thread starter michelle439731
  • Start date Start date
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
 
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.
 
Superb, that is exactly what I wanted to know.

And a history lesson too.

Thank you very much,

Michelle
 
Back
Top