+ Reply to Thread
Results 1 to 3 of 3

Using macros wih different spreadsheets

  1. #1
    Forum Contributor
    Join Date
    03-12-2014
    Location
    Michigan, USA
    MS-Off Ver
    Excel 2016
    Posts
    146

    Using macros wih different spreadsheets

    I have created a template with a macro with keystrokes. I want to use this so at any time I can run a report, then copy/paste that information into my template and run a macro.

    What I do is paste information from the spreadsheet into my template and what the macro does is filter by column O then by column P to show a result of zero in the P column.

    While recording keystrokes, I highlight the first row at the top (leaving the headers) (which in my case the first visible filtered row is 40) and press CTRL+SHIFT+FN+END to highlight everything on the spreadsheet that is visible. Then I right-click and DELETE to get rid of the filtered info.

    I then unfilter P then O to bring up the rest of the information on the spreadsheet.


    When I run the same template and macro but with different spreadsheet information (headers in both sheets are the same) I seem to get different results. I am wondering if the macro I created is remembering specific things from the original spreadsheet I used to create the macro. For example, above I mentioned I clicked on the first row which was row 40 ….. each time I use the macro for different sheets is the macro going to remember that I clicked on line 40 or that I clicked on the second row from the top?

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2406 Win 11 Home 64 Bit
    Posts
    24,024

    Re: Using macros wih different spreadsheets

    Look at this link

    https://www.rondebruin.nl/win/personal.htm
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,926

    Re: Using macros wih different spreadsheets

    The above reference will make the macro available for every workbook you open after updating Personal.XLSB.

    Here are a couple of other options in case you want to limit where you can use this macro:

    The first option is to save the template as an actual Excel Template (XLTM file). Then when you select File -> New, this will be one of the options. This is a good option for a "completed" project. I have one to manage my time sheets.

    Another option is to save the module as a BAS file and import it into workbooks where you need it. I have modules to mail stuff, set filters, clear tables, run queries, get the ASCII equivalent of strings, and so on. When I create a program, I pull in these modules as I need them. This wiki http://www.utteraccess.com/wiki/Add_...ction_To_Excel explains how to export and import BAS files. This is a good option for embedding bits and pieces of code.
    One spreadsheet to rule them all. One spreadsheet to find them. One spreadsheet to bring them all and at corporate, bind them.

    A picture is worth a thousand words, but a sample spreadsheet is more likely to be worked on.

+ 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. Using macros to find duplicates in two spreadsheets
    By sborah99 in forum Excel Programming / VBA / Macros
    Replies: 42
    Last Post: 03-21-2015, 03:54 PM
  2. merging spreadsheets without macros (VBA)
    By kchandra in forum Excel General
    Replies: 1
    Last Post: 01-02-2015, 06:26 PM
  3. Saving spreadsheets with macros for later use.
    By JWML in forum Excel General
    Replies: 3
    Last Post: 06-16-2014, 07:40 PM
  4. Replies: 2
    Last Post: 12-13-2013, 04:58 PM
  5. [SOLVED] Emailing Spreadsheets with embedded Macros
    By MrChips in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 06-03-2012, 03:00 AM
  6. [SOLVED] Finding only spreadsheets with macros
    By davegb in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-21-2006, 11:40 AM
  7. HOW DO I TRANSFER EXCEL SPREADSHEETS WITH QUERIES AND MACROS?
    By Peachtree Help in forum Excel General
    Replies: 1
    Last Post: 03-20-2005, 03:07 AM

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