+ Reply to Thread
Results 1 to 11 of 11

Can't perform an exp() function on VBA

Hybrid View

seigna Can't perform an exp()... 05-05-2013, 10:43 AM
Norie Re: Can't perform an exp()... 05-05-2013, 11:00 AM
seigna Re: Can't perform an exp()... 05-05-2013, 11:04 AM
patel45 Re: Can't perform an exp()... 05-05-2013, 11:04 AM
seigna Re: Can't perform an exp()... 05-05-2013, 11:05 AM
Norie Re: Can't perform an exp()... 05-05-2013, 11:07 AM
seigna Re: Can't perform an exp()... 05-05-2013, 11:15 AM
Norie Re: Can't perform an exp()... 05-05-2013, 11:21 AM
seigna Re: Can't perform an exp()... 05-05-2013, 11:23 AM
Norie Re: Can't perform an exp()... 05-05-2013, 11:28 AM
seigna Re: Can't perform an exp()... 05-05-2013, 11:28 AM
  1. #1
    Forum Contributor
    Join Date
    04-07-2013
    Location
    France
    MS-Off Ver
    Excel 2011
    Posts
    166

    Can't perform an exp() function on VBA

    Hi, I am trying to perform calculations on different columns in an Excel Spreadsheet in VBA, and for that I am using an exp() function. However, I get a result that the argument is not valid? How could I solve this issue?

    Sub Exponent()
        Dim save1 As Double
        Dim save2 As Double
        Dim save3 As Double
        Dim Qconst1 As Integer
        Dim Qconst2 As Integer
        Dim Expon As Double
    
        Qconst1 = -0.5 * Log(2 * WorksheetFunction.Pi) + Log(0.05)
        Qconst2 = 1 / Sqr(2 * WorksheetFunction.Pi)
    
        For i = 9 To 1266
            Sheets(1).Cells(i, 16).Value = Qconst2 / Cells(i, 14) * WorksheetFunction.Exp(-0, 5 * Cells(i, 12) * Cells(i, 12) / Cells(i, 13) / Cells(i, 13)) * 0.01
        Next i
    
    End Sub

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646

    Re: Can't perform an exp() function on VBA

    Why are you apparently passing 2 arguments to WorksheetFunction.Exp?

    Should -0, 5 perhaps be -0.5?
    If posting code please use code tags, see here.

  3. #3
    Forum Contributor
    Join Date
    04-07-2013
    Location
    France
    MS-Off Ver
    Excel 2011
    Posts
    166

    Re: Can't perform an exp() function on VBA

    It's supposed to be only one argument, with the values from different cells.. And, yes, 0.5

  4. #4
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: Can't perform an exp() function on VBA

    WorksheetFunction.Exp(-0, 5 * not correct
    WorksheetFunction.Exp(-0.5 * correct
    If solved remember to mark Thread as solved

  5. #5
    Forum Contributor
    Join Date
    04-07-2013
    Location
    France
    MS-Off Ver
    Excel 2011
    Posts
    166

    Re: Can't perform an exp() function on VBA

    Still, I get a message: Method or Data member not found.. for the Exp function..

  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646

    Re: Can't perform an exp() function on VBA

    Can you upload an example workbook, with the code?

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    View Pic

  7. #7
    Forum Contributor
    Join Date
    04-07-2013
    Location
    France
    MS-Off Ver
    Excel 2011
    Posts
    166

    Re: Can't perform an exp() function on VBA

    Here it comes
    Attached Files Attached Files

  8. #8
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646

    Re: Can't perform an exp() function on VBA

    VBA has it's own Exp function, so remove WorksheetFunction.

  9. #9
    Forum Contributor
    Join Date
    04-07-2013
    Location
    France
    MS-Off Ver
    Excel 2011
    Posts
    166

    Re: Can't perform an exp() function on VBA

    It works somehow.. except that I have a problem with the second column... why is it there?

  10. #10
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646

    Re: Can't perform an exp() function on VBA

    Why is the 2nd column there?

  11. #11
    Forum Contributor
    Join Date
    04-07-2013
    Location
    France
    MS-Off Ver
    Excel 2011
    Posts
    166

    Re: Can't perform an exp() function on VBA

    It's okay, I see why Because I made a copy of something that is empty. It should work otherwise. Thanks.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1