+ Reply to Thread
Results 1 to 12 of 12

Move sheet to ANOTHER workbook, but Macro terminates itself!

  1. #1
    Registered User
    Join Date
    01-31-2012
    Location
    Earth
    MS-Off Ver
    Excel 2007
    Posts
    5

    Unhappy Move sheet to ANOTHER workbook, but Macro terminates itself!

    Please help!! It's a nightmare to see the macro terminates itself without any error prompt....

    Workbook A & B are basically identical, they both have the same macro & name ranges.
    I use A to generate reports and want to move the report sheets to B. (Sounds funny... but it's a request)
    The report sheets are generated thus do not contain any nameranges but don't know why the name conflict message will always prompt, so I must disable DisplayAlert
    Here's my code:
    Please Login or Register  to view this content.
    I could only get "begin move report1" in the immediate window,
    but never seen the "moved" debug print nor other report's debug print...
    I've tried to use COPY instead of MOVE, but same problem occur...
    I'm completely stuck!
    Great Thanks in advance for any suggestion!
    Last edited by alohc; 01-31-2012 at 09:57 PM.

  2. #2
    Forum Expert JapanDave's Avatar
    Join Date
    06-10-2008
    Location
    The grid, I got in!
    MS-Off Ver
    Excel 2010/13
    Posts
    1,696

    Re: Move sheet to ANOTHER workbook, but Macro terminates itself!

    See if this works?

    Please Login or Register  to view this content.
    Be fore warned, I regularly post drunk. So don't take offence (too much) to what I say.
    I am the real 'Napster'
    The Grid. A digital frontier. I tried to picture clusters of information as they moved through the computer. What did they look like? Ships? motorcycles? Were the circuits like freeways? I kept dreaming of a world I thought I'd never see. And then, one day...

    If you receive help please give thanks. Click the * in the bottom left hand corner.

    snb's VBA Help Files

  3. #3
    Forum Expert OnErrorGoto0's Avatar
    Join Date
    12-30-2011
    Location
    I DO NOT POST HERE ANYMORE
    MS-Off Ver
    I DO NOT POST HERE ANYMORE
    Posts
    1,655

    Re: Move sheet to ANOTHER workbook, but Macro terminates itself!

    Please Login or Register  to view this content.
    will not work since dataWs is not a property of the workbook - it is a variable.

    Where is this code located and is there any event code in either workbook that might be in conflict? Also, do you have any UDFs in either workbook that you use in conditional formatting?

    Can you post a sample of the two workbooks (no data necessary in either) that demonstrates the problem?
    Good luck.

  4. #4
    Forum Expert JapanDave's Avatar
    Join Date
    06-10-2008
    Location
    The grid, I got in!
    MS-Off Ver
    Excel 2010/13
    Posts
    1,696

    Re: Move sheet to ANOTHER workbook, but Macro terminates itself!

    Whoops,
    I was meaning to write this, but I still don't know if this will work?

    Please Login or Register  to view this content.

  5. #5
    Forum Expert OnErrorGoto0's Avatar
    Join Date
    12-30-2011
    Location
    I DO NOT POST HERE ANYMORE
    MS-Off Ver
    I DO NOT POST HERE ANYMORE
    Posts
    1,655

    Re: Move sheet to ANOTHER workbook, but Macro terminates itself!

    No - dataWs is already a reference to a specific worksheet so it does not require further qualification.

  6. #6
    Registered User
    Join Date
    01-31-2012
    Location
    Earth
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Move sheet to ANOTHER workbook, but Macro terminates itself!

    First of all, thanks for you help!!

    I tried the following but it still terminates itself...
    Please Login or Register  to view this content.
    Where is this code located and is there any event code in either workbook that might be in conflict? Also, do you have any UDFs in either workbook that you use in conditional formatting?
    Can you post a sample of the two workbooks (no data necessary in either) that demonstrates the problem?
    1. Only Workbook_Open and Workbook_BeforeClose exists, no other event codes (Codes for both wb A & B are identical)
    2. There's no conditional formatting at all.....

    I've attached a simple version of my workbooks. My codes with problem is in the Summary_Move Module.....
    Please place WorkbookB.xls into C:\Temp (or need to modify code)
    Please start by running the "Move Sheet" on WorkbookA.xls and you will see it stops after copying Report 1_GP to workbookB

    Many Thanks!
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    01-31-2012
    Location
    Earth
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Move sheet to ANOTHER workbook, but Macro terminates itself!

    I wonder if there is anything to do with the workbooks' codes being identical...
    (so they have same module, same sub and same functions)
    But the problem is I cannot delete any of the codes!
    Any suggestion??

  8. #8
    Forum Expert JapanDave's Avatar
    Join Date
    06-10-2008
    Location
    The grid, I got in!
    MS-Off Ver
    Excel 2010/13
    Posts
    1,696

    Re: Move sheet to ANOTHER workbook, but Macro terminates itself!

    It is working for me. Copies all reports to workbookB.

  9. #9
    Registered User
    Join Date
    01-31-2012
    Location
    Earth
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Move sheet to ANOTHER workbook, but Macro terminates itself!

    It is working for me. Copies all reports to workbookB.
    JapanDave , do you mean you used my samples and it works fine??
    I've tried on different computers but none work!
    tried different versions of excel too (2003,2007,2010)
    How did you make it work?? Did you change any codes??

  10. #10
    Forum Expert JapanDave's Avatar
    Join Date
    06-10-2008
    Location
    The grid, I got in!
    MS-Off Ver
    Excel 2010/13
    Posts
    1,696

    Re: Move sheet to ANOTHER workbook, but Macro terminates itself!

    This is what I get after running your code, tell me if that is what you are after? BTW, I have not changed anything at all.
    Attached Files Attached Files

  11. #11
    Forum Expert OnErrorGoto0's Avatar
    Join Date
    12-30-2011
    Location
    I DO NOT POST HERE ANYMORE
    MS-Off Ver
    I DO NOT POST HERE ANYMORE
    Posts
    1,655

    Re: Move sheet to ANOTHER workbook, but Macro terminates itself!

    It works for me too.

  12. #12
    Registered User
    Join Date
    01-31-2012
    Location
    Earth
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Move sheet to ANOTHER workbook, but Macro terminates itself!

    JapanDave,
    Yes! The WorkbookB you attached is exactly what it meant to be!
    But it doesn't it work on my laptop! I have only Report1 but no Report2/ReportALL
    It doesn't work on my colleague's laptop as well. We saw the coded jump from workbookA to workbookB, which it shouldn't do so, and stopped.
    I ended up making a batch file to do the copy task.

    Anyway, Thanks for your help!
    And thank you to OnErrorGoto0 too
    As both of you can get it work, I suspect the laptop model might be the cause.

+ 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