+ Reply to Thread
Results 1 to 3 of 3

copying macros

  1. #1
    Registered User
    Join Date
    08-29-2007
    Posts
    45

    copying macros

    with the help of users on this forum I have created a sheet to track items of wastage in a bar environment that uses a piece of code to rename the file with a date at the end of it.

    I also have macors attached to buttons in my workbook that allow me to filter certain types of data, then print the active sheet.

    The question I have is when I run the code that that starts a new sheet with a new filename, my macros that I've attached to the buttons I use to run the filters/print actions don't seem to copy across into the new workbook.

    How can I do this?

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464
    Quote Originally Posted by SRussell
    with the help of users on this forum I have created a sheet to track items of wastage in a bar environment that uses a piece of code to rename the file with a date at the end of it.

    I also have macors attached to buttons in my workbook that allow me to filter certain types of data, then print the active sheet.

    The question I have is when I run the code that that starts a new sheet with a new filename, my macros that I've attached to the buttons I use to run the filters/print actions don't seem to copy across into the new workbook.

    How can I do this?
    Hi,

    Yes indeed, creating and copying into a new workbook doesn't, as you've found, copy anything from the VBE. The technique is to export the .bas module file, and import it to the new workbook, using lines of code like the ones below at the appropriate places in your macro.

    Alternatively, and a technique I've used before, is to filter the data you want to present to an appropriate place, then immediately save the workbook, and then a copy of it with the new name. Now activate the copy and if there's stuff in the workbook that you don't want the recipient to get, delete it all and save again, before closing it and reopening the original master workbook if necessary. This avoids the need for exporting the .bas module


    Please Login or Register  to view this content.
    HTH

  3. #3
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    I would recommend creating a Template workbook. See

    http://www.excel-it.com/excel_templates.htm
    Hope that helps.

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

    Free DataBaseForm example

+ 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