+ Reply to Thread
Results 1 to 2 of 2

Copying sheets to a new WB, but macros are still referencing the old WB?

  1. #1
    Registered User
    Join Date
    11-13-2013
    Location
    Toronto
    MS-Off Ver
    Excel 2010
    Posts
    1

    Copying sheets to a new WB, but macros are still referencing the old WB?

    Hey everyone!

    Hoping someone can help. I've got some code that copies a couple of sheets within my main workbook into a new workbook, and saves the new file. Just a simple SaveAs:

    Please Login or Register  to view this content.
    The sheets I copy over to the new workbook to be saved contain a number of macros, all of which function fine except for one small problem: they modify the old workbook and not the new one!

    All of the macros are contained within the sheet code and not modules, and I even have code referencing the new wb in all of the relevant macros, like this:

    Please Login or Register  to view this content.
    Etc, which causes some of the macros in the new sheet to function properly, but is a pretty inelegant solution, and other macros still perplexingly reference the old wb.

    When I look at the macros assigned to my my buttons I see the macro name as being the following:

    2015-02-19 11-40-54 AM.jpg

    So as opposed to being simply "Sheet1.home_" or even "MyNewWorkBookName!Sheet1.home_" it's still referencing the old workbook in every macro in the new workbook (Job Aid Creator being the name of the old workbook).

    Is there any way to make this work before / after copying the sheets over and saving the new workbook?

    Thanks!!

  2. #2
    Forum Guru
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Copying sheets to a new WB, but macros are still referencing the old WB?

    Hi Gumbeez,

    See post #2 in the following thread. It may solve your problem. http://www.excelforum.com/excel-prog...ml#post3989628

    Lewis

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Copying sheets and macros to new workbook
    By TheRealLethality in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-16-2014, 10:40 AM
  2. Replies: 5
    Last Post: 12-09-2012, 04:27 PM
  3. Referencing sheets after copying
    By tone640 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-30-2011, 08:50 AM
  4. Copying Sheets from other Workbooks w/o referencing
    By mremmenga in forum Excel General
    Replies: 2
    Last Post: 10-24-2008, 05:24 AM
  5. [SOLVED] Copying formulas referencing multiple sheets
    By JA in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-10-2006, 08:25 PM

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