Results 1 to 4 of 4
  1. #1
    Lounger
    Join Date
    Mar 2005
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Random Numbers (2003/sp2)

    I would appreciate some help with the following problem:

    I am trying to create a macro that uses the 'Random Number Generation' function in the Analysis Toolpak. The optimal solution would be to have a VBA button that runs the Random number generation function The parameters for the function would be integers in specified cells i.e D5 = the integer for the mean, D6 = the integer for the standard deviation etc. A random number would then be generated each time the VB button is clicked on in a specified cell. I tried to record a macro while using this function and it looked like this:

    Sub Random()
    '
    AddIns("Analysis ToolPak").Installed = True
    Application.Run "ATPVBAEN.XLA!Random", ActiveSheet.Range("$F$19"), 1, 1, _
    2, , 5, 1
    End Sub

    When I try to run it, however, I get an error message 'ATPVBAEN.XLA' could not be found, a runtime error '1004.'

    Any idea how to make this work. Thanks much in advance.

    Altin

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Random Numbers (2003/sp2)

    You need to ensure that Analysis Toolpak - VBA is installed:

    AddIns("Analysis ToolPak - VBA").Installed = True

  3. #3
    Lounger
    Join Date
    Mar 2005
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Random Numbers (2003/sp2)

    Thanks much Hans, that seems to work!

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Random Numbers (2003/sp2)

    The Analysis Toolpak add-in (Analysis.xll) provides the functions for the user interface, and the Analysis Toolpak - VBA add-in (ATPVBAEN.xla) provides the equivalent VBA functions. So the latter is the one you need for your code.

Posting Permissions

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