Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have an Excel file that was done in Excel 97-2003. It contains a macro. The macro runs fine in Excel 2010 but have now had to convert to Excel 2013 and the macro does not work. I am only a basic user on macros; can someone point me in the right direction? I get "Error 9". I tried to understand the debugger but I could not figure it out.

            AllowFormattingColumns:=True, _
            AllowFormattingRows:=True

            Sheets("Print-Send").Select
            Cells(counter, "D").Select
            ActiveCell.FormulaR1C1 = ("")
            Sheets(model).Select
            Sheets(model).Move _
                After:=Workbooks("Compressed CPC.xls").Sheets(3) 'error here
            Range("B4").Select
            Selection.ClearComments
            Range("A8").Select
            Selection.ClearComments
        End If
        counter = counter + 1
    Loop
End With
share|improve this question
3  
We can not help you without the complete macro code. Paste it at pastebin.com and edit the link to your question. If there are multiple modules, paste & link every module as separate link –  nixda Jan 21 at 16:32
    
Or at least edit your question and post the section that's throwing the error. As-is, this is WAY to vague. –  Ƭᴇcʜιᴇ007 Jan 21 at 17:50
    
Sorry Guys. being blocked from pastebin.com. is it ok to post the txt from the debugger here? –  Valerie Jan 21 at 18:05
    
An* is in front of the line the debugger says is bad AllowFormattingColumns:=True, _ AllowFormattingRows:=True Sheets("Print-Send").Select Cells(counter, "D").Select ActiveCell.FormulaR1C1 = ("") Sheets(model).Select *Sheets(model).Move After:=Workbooks("Compressed CPC.xls").Sheets(3) Range("B4").Select Selection.ClearComments Range("A8").Select Selection.ClearComments End If counter = counter + 1 Loop End With –  Valerie Jan 21 at 18:09
    
Please edit it into your question, and use the code formatting features of the editor. –  Ƭᴇcʜιᴇ007 Jan 21 at 18:18

1 Answer 1

Based on the limited code you posted, I have some guesses

  • Do you have the workbook "Comproessed CPC.xls" open when the code is run?
  • Does the workbook "Compressed CPC.xls" have 3 sheets in it?

And doing some further research it looks like Error 9 may have to do with getting data from a closed workbook. As found in an article from www.excelsuperstar.com titled "VBA Runtime Error 9 – Data From A Closed Workbook"

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.