Loading
Ozgrid Excel Help & Best Practices Forums

Excel Video Tutorials / Excel Dashboards Reports



Results 1 to 4 of 4

Thread: LN function in VBA

  1. #1
    Join Date
    22nd November 2004
    Location
    London
    Posts
    133

    LN function in VBA

    I have a routine which is used to generate time values based on the probability of observing one of two events. Becasue the times are being generated from an inverse exponential distribution by generating a uniform random variable and then solving the equation U=1-e^(lambda*x) in terms of x. I am left with having to generate x by using the 'Range.select - Activecell.formula' format which can be quite slow when thousands of variables are generated. Therefore my question is, is there anyway to define the LN function so I can use it without having to select the range. I am finding it a little strange that excel gave me an error when I tried to use the formula using just variables.

    Excel Video Tutorials / Excel Dashboards Reports


  2. #2
    Join Date
    24th January 2003
    Location
    Australia
    Posts
    31,717

    Re: LN function in VBA

    Not too sure what you really need but you can pass a cells formula, or result of via either of the 2 methods below;

    VB:
    myVariable=Sheet1.Range("A1").formula 
     'OR
    myVariable=Sheet1.Range("A1") 
    
    
    To use the LN Function in VBA precede it with WorksheetFunction:
    VB:
    WorksheetFunction.LN 
    
    

  3. #3
    Join Date
    22nd November 2004
    Location
    London
    Posts
    133

    Re: LN function in VBA

    Thanks again Dave, all i needed was that one line.

    Excel Video Tutorials / Excel Dashboards Reports


  4. #4
    Join Date
    15th April 2003
    Location
    USA
    Posts
    7,394

    Re: LN function in VBA

    VBA has its own natural log function, Log. It should be more efficient to use it rather than referring to the worksheet function if you are making many calls.
    Please do not U2U (private message) me directly for questions that should be posted to the forum; any such U2Us will be ignored.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Possible Answers

  1. Date Function - NOW Function - Excel 2007 NOW Function
    By Dave Hawley in forum Excel Formulas (No Questions)
    Replies: 0
    Last Post: July 10th, 2008, 02:33
  2. Date Function - NOW Function - Excel 2007 NOW Function
    By Dave Hawley in forum Excel Formulas (No Questions)
    Replies: 0
    Last Post: July 10th, 2008, 02:32
  3. Date Function - NOW Function - Excel 2007 NOW Function
    By Dave Hawley in forum Excel Formulas (No Questions)
    Replies: 0
    Last Post: July 10th, 2008, 02:31
  4. XL98: How to Display Custom Function in Function Wizard Step 2
    By Dave Hawley in forum Excel Formulas (No Questions)
    Replies: 0
    Last Post: April 11th, 2008, 14:15
  5. XL2000: Cannot See User-Defined Function in the Paste Function Dialog ...
    By Dave Hawley in forum Excel Formulas (No Questions)
    Replies: 0
    Last Post: April 11th, 2008, 14:15

Bookmarks

Posting Permissions

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