+ Reply to Thread
Results 1 to 11 of 11

Inserting a worksheet into another workbook loses its macro in the journey

  1. #1
    Registered User
    Join Date
    04-14-2014
    Location
    Laguna Niguel, CA
    MS-Off Ver
    Version 2404
    Posts
    44

    Inserting a worksheet into another workbook loses its macro in the journey

    What am I doing wrong?

    Thank you,

  2. #2
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Inserting a worksheet into another workbook loses its macro in the journey

    Hi, Bill Allen,

    kind of hard to tell if you don´t post the code and the extensions of the workbooks involved.

    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  3. #3
    Registered User
    Join Date
    04-14-2014
    Location
    Laguna Niguel, CA
    MS-Off Ver
    Version 2404
    Posts
    44

    Re: Inserting a worksheet into another workbook loses its macro in the journey

    Sorry. Didn't think my problem was dependent on the code. Here it is:


    Sub Calculate_K()
    '
    ' Calculate_K Macro
    '
    ' Keyboard Shortcut: Ctrl+Shift+K
    '
    Range("O43").GoalSeek Goal:=0, ChangingCell:=Range("F42")
    End Sub


    Quote Originally Posted by HaHoBe View Post
    Hi, Bill Allen,

    kind of hard to tell if you don´t post the code and the extensions of the workbooks involved.

    Ciao,
    Holger

  4. #4
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Inserting a worksheet into another workbook loses its macro in the journey

    Hi, Bill Allen,

    please have a look at Forum Rule #3 and add code-tags to your procedure. I´d expected that code to be located in a standrad module, not behind a worksheet.

    Ciao,
    Holger

  5. #5
    Registered User
    Join Date
    04-14-2014
    Location
    Laguna Niguel, CA
    MS-Off Ver
    Version 2404
    Posts
    44

    Re: Inserting a worksheet into another workbook loses its macro in the journey

    Are you saying that some worksheets containing macros can be inserted into other workbooks but some cannot due to the specific coding of the macro?

  6. #6
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Inserting a worksheet into another workbook loses its macro in the journey

    Hi, Bill Allen,

    what I wanted to say: you posted the macro that gets lost according to you but not the way you copy (via Macro or by hand) nor the extensions of the files concerned.

    Ciao,
    Holger

  7. #7
    Registered User
    Join Date
    04-14-2014
    Location
    Laguna Niguel, CA
    MS-Off Ver
    Version 2404
    Posts
    44

    Re: Inserting a worksheet into another workbook loses its macro in the journey

    Right. When I insert the worksheet containing the macro into a workbook that I'm building (from templates in my library), I get an error message that reads:
    macro.jpg

  8. #8
    Registered User
    Join Date
    04-14-2014
    Location
    Laguna Niguel, CA
    MS-Off Ver
    Version 2404
    Posts
    44

    Re: Inserting a worksheet into another workbook loses its macro in the journey

    Right. I try to insert the worksheet with the macro into another workbook and I get this error message:

    macro.jpg

  9. #9
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Inserting a worksheet into another workbook loses its macro in the journey

    Hi, Bill Allen,

    open the basic workbook, press ALT+F11 to enter the VBE, expand to see all objects in the Project Browser, double click on the sheet you want to copy and look into the code window: any macro being presented there? I can´t see it from my pc or in my crystal marble.

    Ciao,
    Holger

  10. #10
    Registered User
    Join Date
    04-14-2014
    Location
    Laguna Niguel, CA
    MS-Off Ver
    Version 2404
    Posts
    44

    Re: Inserting a worksheet into another workbook loses its macro in the journey

    Perhaps this is where we are having a communication problem. When I say "copy" a worksheet into another workbook, the way I do this is to have the main workbook open and, when I want to insert the worksheet with the macro in it (or any other of my worksheets from my library), I right mouse click the sheet tab and then select Insert from the pop out menu. At that point, I insert the worksheet with the macro in it into the main workbook. When I do that, the worksheet comes in but the macro cannot be found. Using your test method, I have verified that the macro did not come with the spreadsheet.

  11. #11
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Inserting a worksheet into another workbook loses its macro in the journey

    Hi, Bill Allen,

    the basic workbook is not the workbook you want to copy to but the one you copy from.

    Ciao,
    Holger

+ 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. [SOLVED] Inserting Cells loses Formula
    By Jennsy in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 07-22-2013, 05:07 AM
  2. VB code error when workbook loses focus
    By Protiusmime in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 10-12-2008, 12:43 AM
  3. Inserting a worksheet into an open workbook via VBA code
    By manillla in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-13-2005, 09:05 PM
  4. INserting a worksheet from one workbook to another workbook
    By Billy in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 05-31-2005, 08:05 PM
  5. Inserting a worksheet from external workbook
    By Hall in forum Excel General
    Replies: 2
    Last Post: 02-23-2005, 06:06 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