+ Reply to Thread
Results 1 to 2 of 2

Macro to Create Button and Assign ClearFilters Command in a Different Workbook

  1. #1
    Registered User
    Join Date
    08-09-2012
    Location
    Memphis, TN
    MS-Off Ver
    Excel 2010
    Posts
    22

    Macro to Create Button and Assign ClearFilters Command in a Different Workbook

    I have an analysis workbook with multiple tabs that is too large to share with a broader audience and so I have created a macro which summarizes the results of the analysis on a new tab, copies that tab to a new workbook and then saves that workbook under a new name. As a part of the macro I create two buttons....the first button clears filters from the worksheet and the second button selects a defined range and prompts the sort command.

    My problems is that when the sheet copies to a new workbook it retains the buttons but loses the connection to the underlying macros that were assigned to them....is there a way to either 1) export the module/macro with the sheet as it is copied to a new workbook or 2) to have the code write the macro in the new workbook so that it can be assigned to the buttons. Any help with this question would be greatly appreciated.

    Here is a copy of the code I use to reset filters and prompt the sort command.

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.

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

    Re: Macro to Create Button and Assign ClearFilters Command in a Different Workbook

    Hi hurst2008,

    The following Macro may help you get started. It identifies Macros (associated with Shapes) that refer to another workbook, and replaces the reference with a reference (actually no reference) to the workbook that is running the code. See the attached file that implements the Macro.

    My speculation is that someone else has a much simpler solution for your problem. I have used this and similar code for references in chart data and formulas.

    Lewis

    Please Login or Register  to view this content.

+ 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. Replies: 0
    Last Post: 01-15-2013, 08:18 PM
  2. Macro to create Command Button and assign code
    By dagindi in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-07-2011, 09:19 AM
  3. Copy Sheet with Command Button to new Worbook and assign macro in new workbook
    By grey in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-07-2010, 05:33 AM
  4. How to create a command button and assign code to it using VBA?
    By surotkin in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-04-2007, 10:05 PM
  5. Replies: 2
    Last Post: 06-05-2005, 11:05 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