+ Reply to Thread
Results 1 to 7 of 7

Change recorded macro to work for active sheets

  1. #1
    Registered User
    Join Date
    07-01-2020
    Location
    Yerevan
    MS-Off Ver
    2010
    Posts
    44

    Change recorded macro to work for active sheets

    Hi All,

    I have recorded a macro which you can find below. I want to save this for future use. However, in recorded macro it specifies the sheet, but I would like not specify sheet name so that it works for other active sheets.

    Can you advise what I need to change so that it works for active sheets?

    Please Login or Register  to view this content.
    Last edited by lilit2222; 07-02-2020 at 09:27 AM.

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,656

    Re: Change recorded macro to work for active sheets

    Administrative Note:

    Welcome to the forum.

    We would very much like to help you with your query, however you need to include code tags around your code.

    Please take a moment to add the tags. Posting code between tags makes your code much easier to read and copy for testing, and it also maintains VBA formatting.

    Please see Forum Rule #2 about code tags and adjust accordingly. Click on Edit to open your post, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    (Note: this change is not optional. As you are new, I will do it for you today.)
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,907

    Re: Change recorded macro to work for active sheets

    Something like this:

    Please Login or Register  to view this content.
    Rory

  4. #4
    Registered User
    Join Date
    07-01-2020
    Location
    Yerevan
    MS-Off Ver
    2010
    Posts
    44

    Re: Change recorded macro to work for active sheets

    Attachment 685051

    I have tries this before but when I click run error 1004 appears- application defined error

  5. #5
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,907

    Re: Change recorded macro to work for active sheets

    I can't see that attachment. Which line causes the error?

  6. #6
    Registered User
    Join Date
    07-01-2020
    Location
    Yerevan
    MS-Off Ver
    2010
    Posts
    44

    Re: Change recorded macro to work for active sheets

    Attachment 685053

    Can you see it now?

    It is the last line starting with .apply
    Attached Images Attached Images

  7. #7
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,907

    Re: Change recorded macro to work for active sheets

    Is the sheet protected? Do you have more than one sheet selected?

+ 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] Change VBA Code so that it work on All Sheets and not only on Active Sheet.
    By Chypp in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 12-28-2017, 12:45 PM
  2. Change a recorded macro so it works for the "Active Tab" and not a specified tab.
    By almst791 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-15-2017, 02:44 PM
  3. Fixing Macro to work in active sheets
    By PWilson0727 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-04-2015, 05:37 PM
  4. Editing my recorded macro to get it to work despite a range length change
    By dasseya1 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-15-2013, 11:15 AM
  5. [SOLVED] Why wont my search function work when i change it from all sheets to active sheet?
    By joshnathan in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-03-2012, 12:58 PM
  6. Recorded Macro Does Not Work
    By TheColorLavender in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-05-2012, 01:56 AM
  7. Make Macro work accross all active (grouped) sheets
    By CRIMEDOG in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-27-2009, 01:44 PM

Tags for this Thread

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