Excel Data Analysis Macro Error

Anonymous
2016-06-09T21:56:20+00:00

Hello,

I am trying to use the record macro feature using the regression tool in the data analysis toolpack. However, every time I try to run the macro I get the error message:

Run-time error '1004':

Sorry, we couldn't find

C:\Users\myaccountname\Documents\ATPVBAEN.XLAM. Is it possible it was moved, renamed or deleted?

The code itself looks like this:

Sub Macro13()

'

' Macro13 Macro

'

'

     Application.Run "ATPVBAEN.XLAM!Regress", ActiveSheet.Range("$N$4:$N$18"), _

        ActiveSheet.Range("$O$4:$O$18"), False, False, 95, ActiveSheet.Range( _

        "$Q$3:$AD$33"), False, False, False, False, , True

End Sub

I tried replacing ATPVBAEN.XLAM with 'Analysis Toolpak - VBA' as described in this link:

https://support.microsoft.com/en-us/kb/192642

However it does not work. Does anyone know how to solve this issue?

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments
{count} votes
Answer accepted by question author
  1. Anonymous
    2016-06-10T00:34:29+00:00

    Worked ok for me using Excel 2016.

    Make sure you go to File | Options | Add-ins | 

    Under Manage "Excel Add-ins", <Go ...>   make sure you have "Analysis Tookpak - vba"  selected.

    Or:  In the vba editor, you can also go to Tools : Reference, and check "atpvbaen.xls"

    Then, this code worked for me:  I just used the upper left corner reference for the output.

    Sub Demo()

    Regress Range("$N$4:$N$18"), Range("$O$4:$O$18"), False, False, 95, Range("$Q$3"), False, False, False, False, , True

    End Sub

    0 comments No comments

3 additional answers

Sort by: Most helpful
  1. Anonymous
    2016-06-10T13:03:11+00:00

    Hey Dana D_ 

    That fixed it. Thank you!

    0 comments No comments
  2. Anonymous
    2017-04-03T19:44:25+00:00

    Hi Dana,

    I originally had the same error with my code (ATPVBAEN.XLAM!Fourier) and followed the following:

    Under Manage "Excel Add-ins", <Go ...>   make sure you have "Analysis Tookpak - vba"  selected.

    Or:  In the vba editor, you can also go to Tools : Reference, and check "atpvbaen.xls"

    However, now I am getting the error ["Run-time error '1004': Cannot run the macro ". The macro may not be available in this workbook or all macros may be disabled." ]

    The macros shouldn't be disabled because I use many other macros in this sheet and it is saved as a macro enabled sheet. 

    Any suggestions on what the issue may be ?

    0 comments No comments
  3. Anonymous
    2017-08-03T06:58:18+00:00

    The problem is that when you run a macro outside excel the add ins do not load. Here you are trying to run the regression analysis which requires the ATPVBAEN.XLAM add in. In this case you need to load add ins manually. An example in vb-script to manually activate add in and run macro is given below:

    Set objExcel = CreateObject("Excel.Application")

    objExcel.Workbooks.Open (objExcel.librarypath & "\Analysis\ATPVBAEN.XLAM")

    objExcel.RegisterXLL "Analys32.xll"

    objExcel.Workbooks("atpvbaen.xlam").RunAutoMacros 1

    objExcel.Application.Run "'C:\specify your file path.xlsm'!your macro name"

    objExcel.DisplayAlerts = False

    objExcel.Application.Quit

    Set objExcel = Nothing

    0 comments No comments