+ Reply to Thread
Results 1 to 6 of 6

Make a macro run on only a specified worksheet regardless of which sheet is active.

  1. #1
    Registered User
    Join Date
    09-06-2013
    Location
    Northamptonshire, England
    MS-Off Ver
    Excel 2003
    Posts
    45

    Make a macro run on only a specified worksheet regardless of which sheet is active.

    Hi all,

    I'm aware that this may seem like a pretty simple issue, but i was wondering what coding is required to ensure that a Macro only runs on a sheet with a specific name regardless of which sheet it currently active?

    The Macro is fairly simple in nature as it is sorting columns etc and I have managed to get the macro working correctly so long as the sheet in question is currently active.

    The eventual aim is to have an additional macro that will run a series of macros each relating to one specific sheet. I have discovered that in order to do this i first need to ensure that each macro can only run on the 1 sheet it is designed for.

    This is an obstacle that i'm sure is simple enough to overcome but am currently having no luck.

    Any help would be appreciated.

    Thank you.
    Ethan

  2. #2
    Registered User
    Join Date
    02-20-2014
    Location
    Wales
    MS-Off Ver
    Excel 2010
    Posts
    87

    Re: Make a macro run on only a specified worksheet regardless of which sheet is active.

    You could use the following:

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    09-06-2013
    Location
    Northamptonshire, England
    MS-Off Ver
    Excel 2003
    Posts
    45

    Re: Make a macro run on only a specified worksheet regardless of which sheet is active.

    Thanks Estratosphere. Would that code go at the very beginning of my macro
    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    02-20-2014
    Location
    Wales
    MS-Off Ver
    Excel 2010
    Posts
    87

    Re: Make a macro run on only a specified worksheet regardless of which sheet is active.

    Yes it would. Will stop the active sheet changing but run the macro, in place of the .select line

  5. #5
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Make a macro run on only a specified worksheet regardless of which sheet is active.

    It would help if you posted an example of the code, but essentially you should qualify all range/cells references with the relevant worksheet - i.e. use
    Please Login or Register  to view this content.
    rather than just:
    Please Login or Register  to view this content.
    in your code. You could also move the routines to the sheets that they are supposed to manipulate, then any .Range/.Cells properties will default to that sheet anyway.
    Remember what the dormouse said
    Feed your head

  6. #6
    Registered User
    Join Date
    09-06-2013
    Location
    Northamptonshire, England
    MS-Off Ver
    Excel 2003
    Posts
    45

    Re: Make a macro run on only a specified worksheet regardless of which sheet is active.

    Excellent.

    Thank you both for your advise/feedback. It's very much appreciated.
    Have a good evening both.

    Regards
    Ethan

+ 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. Macro to go back to the last active sheet and hide the active sheet
    By yatahaze in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-20-2014, 08:18 AM
  2. Replies: 1
    Last Post: 07-07-2014, 09:19 AM
  3. Make this macro select active sheet
    By smugglersblues in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-10-2013, 07:18 PM
  4. Replies: 0
    Last Post: 04-28-2012, 06:06 PM
  5. Replies: 3
    Last Post: 11-18-2005, 05:00 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