none
Macro run time error '9' RRS feed

  • Question

  • I have recently upgraded to 365 from 2003.

    I use a spreadsheet to generate reports. When I click create report I now get a run time error '9'. Subscript out of range.

    When I click de bug i get:

    Sub FormatReport1(Leesee As String, RptDate As Date, AssumedCostOfFunds As Double)
        xlApp.Sheets("Sheet2").Select   THIS LINE IS HIGHLIGHTED IN YELLOW
        xlApp.Sheets("Sheet2").PageSetup.Orientation = xlLandscape
        xlApp.Sheets("Sheet2").PageSetup.Zoom = 80
        xlApp.Sheets("Sheet2").PageSetup.LeftMargin = Application.InchesToPoints(0.15748031496063)
        xlApp.Sheets("Sheet2").PageSetup.RightMargin = Application.InchesToPoints(0.15748031496063)
        xlApp.Sheets("Sheet2").PageSetup.TopMargin = Application.InchesToPoints(0.393700787401575)
        xlApp.Sheets("Sheet2").PageSetup.BottomMargin = Application.InchesToPoints(0.393700787401575)
        xlApp.Sheets("Sheet2").Name = "Report 1"

    Can anyone explain why my macros don't work now I am using 365.

    Thursday, May 21, 2015 10:14 AM

Answers

  • Hi PhilipGH,

    >>When I click create report I now get a run time error '9'. Subscript out of range.<<

    Based on the error message and the error code, it shoult be relative to the index of worksheets. Please ensure that the 'Sheet2' exits.

    Hope it is helpful.

    Regards & Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Monday, May 25, 2015 2:43 AM
    Moderator

All replies

  • Hi,

    This is the forum to discuss questions and feedback for Microsoft Excel, I'll move your question to the MSDN forum for Excel

    http://social.msdn.microsoft.com/Forums/en-US/home?forum=exceldev&filter=alltypes&sort=lastpostdesc

    The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us. Thank you for your understanding.

    George Zhao
    TechNet Community Support


    It's recommended to download and install Configuration Analyzer Tool (OffCAT), which is developed by Microsoft Support teams. Once the tool is installed, you can run it at any time to scan for hundreds of known issues in Office programs.

    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact tnmff@microsoft.com.
    Friday, May 22, 2015 2:12 AM
  • Hi PhilipGH,

    >>When I click create report I now get a run time error '9'. Subscript out of range.<<

    Based on the error message and the error code, it shoult be relative to the index of worksheets. Please ensure that the 'Sheet2' exits.

    Hope it is helpful.

    Regards & Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Monday, May 25, 2015 2:43 AM
    Moderator
  • Hi Fei Xue,

    Not sure what you mean by making sure "sheet 2 exits"?

    Thanks 

    Thursday, May 28, 2015 1:49 PM