+ Reply to Thread
Results 1 to 3 of 3

Copying macro from one file to another

  1. #1
    Registered User
    Join Date
    12-10-2009
    Location
    plano
    MS-Off Ver
    Excel 2007
    Posts
    11

    Copying macro from one file to another

    Hello,

    I am working on two macros and both are currently in same file A: Running first macro asks user input for the name of file B and creates it. It also creates a button in file B which is linked to second macro in file A. When more input is entered in File B and button is clicked, it calls second macro in file A. In the first macro when button is assigned to second macro, the name of file A is also coded.

    For this happen, it is necessary to have file A same name (another unkown user might change the file name and macro will not run or give error) and file A remain open. I found that even though file A is closed, clicking the button opens the file and runs the second macro in File A.

    this is the code for button:
    Please Login or Register  to view this content.
    I would like to know how can I copy the second macro into file B while its being created so clicking button in file B will run the second macro which is located in the same file. any other options?
    Last edited by royUK; 01-02-2010 at 04:27 AM. Reason: add code tags

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    re: Copying macro from one file to another

    Your post does not comply with Rule 1 of our Forum RULES. Your post title should accurately and concisely describe your problem, not your anticipated solution. Use terms appropriate to a Google search. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will be addressed according to the OP's experience in the forum: If you have less than 10 posts, expect (and respond to) a request to change your thread title. If you have 10 or more posts, expect your post to be locked, so you can start a new thread with an appropriate title.
    To change a Title on your post, click EDIT then Go Advanced and change your title, if 2 days have passed ask a moderator to do it for you.

    Edited this time
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Copying macro from one file to another

    The simplest way would be to have the code in your PERSONAL.xlsm or an addin then it would be availabletoall workbooks

+ 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