+ Reply to Thread
Results 1 to 12 of 12

Auto_Deactivate can't find Macro

  1. #1
    Registered User
    Join Date
    01-31-2013
    Location
    Burlington, Ontario
    MS-Off Ver
    Excel 2010
    Posts
    21

    Auto_Deactivate can't find Macro

    I have a simple range copy macro that I would like to have run when the "Data" sheet is deactivated. I defined the name as "Data!RitTest" and used the reference of "Deactivate_Test!RitTest.

    The problem I can't fix is that the macro isn't found - I get the error : "Cannot find Deactivate_Test!RitTest.

    I assume that I'm doing something fundamentally wrong in either the naming conventions or how I am trying to call the macro. Please let me know if anyone can help me with this problem.

    Thanks.

    CDEG
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Auto_Deactivate can't find Macro

    Hi

    Deactivate is a sheet specific macro name.

    So you need to save your code in the sheet specific area.

    Right click pn the sheet name at the bottom of excel

    On left tab select worksheet

    on right tab select deactivate

    paste you code between Sub and end sub.

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

    Re: Auto_Deactivate can't find Macro

    How exactly are you trying to run the macro?

    What is it's name 'RitTest'?

    I've looked at the workbook and I can't see any sub/function with that name.

    I also found this, commented out, in the module of worksheet 'Data'.
    Please Login or Register  to view this content.
    What are you trying to do?
    If posting code please use code tags, see here.

  4. #4
    Registered User
    Join Date
    01-31-2013
    Location
    Burlington, Ontario
    MS-Off Ver
    Excel 2010
    Posts
    21

    Re: Auto_Deactivate can't find Macro

    I have an auto refreshing pivot table on the “report” sheet. This pivot table uses the data from the data sheet. Before I move from the data sheet, I want the formulas in CopyRange to copy down through Pivot_Range so that I know that all of the pivot table data is properly refreshed .
    When I put the copy code into the worksheet module using Worksheet_Deactivate, and I move to the Report sheet, the copy macro runs fine, but I get a run-time error ‘1004’: unable to get the pivot tables property of the worksheet class.
    Attached Files Attached Files

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

    Re: Auto_Deactivate can't find Macro

    Change ActiveSheet in the code to reference explicitly the sheet that has the pivot tables.
    Please Login or Register  to view this content.
    You should do that wherever you've used ActiveSheet.

  6. #6
    Registered User
    Join Date
    01-31-2013
    Location
    Burlington, Ontario
    MS-Off Ver
    Excel 2010
    Posts
    21

    Re: Auto_Deactivate can't find Macro

    Okay. That's great. Everything is working now and I only have one more problem. I know I've see nsolutions to similar problems, but I'm not sure they pertain to this specfic situation. When I move to the report sheet, the macro runs and end up back on the Data sheet. Is there something I can do to remain on the Report sheet?

  7. #7
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644
    You could add code to return to the report sheet.

    Mind you that could cause problems as it might trigger an event.

    Might even end up in some sort of vicious circle.

    I'll have another look at the file.

  8. #8
    Registered User
    Join Date
    01-31-2013
    Location
    Burlington, Ontario
    MS-Off Ver
    Excel 2010
    Posts
    21

    Re: Auto_Deactivate can't find Macro

    Thanks, Norie. Yes, that does start an infinite loop.

  9. #9
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644
    You could disable events.
    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    01-31-2013
    Location
    Burlington, Ontario
    MS-Off Ver
    Excel 2010
    Posts
    21

    Re: Auto_Deactivate can't find Macro

    Norie, I can't seem to get this to work - where exactly would this code be entered?

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

    Re: Auto_Deactivate can't find Macro

    Change the code that copies CopyRange to FomulaRange to this.
    Please Login or Register  to view this content.

  12. #12
    Registered User
    Join Date
    01-31-2013
    Location
    Burlington, Ontario
    MS-Off Ver
    Excel 2010
    Posts
    21

    Re: Auto_Deactivate can't find Macro

    That is absolutely perfect! Thanks very much for your perserverance in getting this solution for me. It is very much appreciated.

    Regards,

    Craig

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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