Results 1 to 5 of 5

Thread: Excel 2000 VBA math functions

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2003
    Posts
    2

    Excel 2000 VBA math functions

    While I have been a programmer for quite a while, I am a novice to Excel VBA and VB in general.

    I need to use both log to the base 10 [Log ... mathematics notation] and the natural log [Ln]. Excel has Ln, LOG10, and LOG(n,b). Unfortunately, I only find Log in the VBA math library. Even weider the VBA Log function appears to actually be the natural log rather than common log.

    Can someone explain if what I have seen is strange or standard. Are there Log10, Log(n,b) and Ln function in a VBA library?

  2. #2
    Fanatic Member WorkHorse's Avatar
    Join Date
    Jul 2002
    Location
    Where you live.
    Posts
    591
    The Log that you see is the standard VB Log function. To use the Excel worksheet functions, you must use Application.WorksheetFunction. Example:

    VB Code:
    1. 'Uses Excel worksheet function.
    2. MsgBox Application.WorksheetFunction.Log(86)
    3.  
    4. 'Uses VB Log function.
    5. MsgBox Log(86)

  3. #3

    Thread Starter
    New Member
    Join Date
    Jun 2003
    Posts
    2
    Thanks for the assist. I had not found the application method.

  4. #4
    Lively Member
    Join Date
    Apr 2003
    Location
    Georgetown, Texas
    Posts
    114

    Excel VBA math functions

    On an Excel spreadsheet, I entered:

    =LOG(10) and got 1
    =LOG(100) and got 2
    =LN(10) and got 2.302585

    So, both base 10 and natural logarithms are available in my Excel 97.

  5. #5
    Lively Member
    Join Date
    Apr 2003
    Location
    Georgetown, Texas
    Posts
    114
    I have no idea how my name got on the previous reply, which was made PRIOR to my intent, by some other person! I thought I had posted something like:

    To get the base 10 logarithm of a number, since it is equal to the natural logarithm of the number, divided by the natural logarithmod 10, use this, for y = log10(x):

    y = ln(x)/ln(10) which, in BASIC, QuickBASIC, VB and VBA is:

    y = log(x)/log(10)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width