+ Reply to Thread
Results 1 to 4 of 4

Code to Mimic On Activate

  1. #1
    Forum Contributor
    Join Date
    07-10-2020
    Location
    New Zealand
    MS-Off Ver
    365 personal
    Posts
    302

    Code to Mimic On Activate

    Hi
    I need some Code that will mimic what happens when you click on the tab for another sheet and back to the original Sheet. I need this to Trigger the On Activate Code of the first sheet.

    I recorded the following but it does trigger the On Activate.

    Does anyone have any ideas ?

    Thanks

    Allister

    Please Login or Register  to view this content.
    Last edited by AllisterB; 05-12-2021 at 06:55 AM.

  2. #2
    Forum Expert
    Join Date
    05-29-2020
    Location
    NH USA
    MS-Off Ver
    365
    Posts
    2,103

    Re: Code to Mimic On Activate

    Try

    Please Login or Register  to view this content.

  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,908

    Re: Code to Mimic On Activate

    If you mean that you want to trigger the worksheet_activate event for that sheet, then you should probably move the code out of that event into a separate routine in a new module, and call that from the Activate event and this macro. You can use Application.Run to call the event code directly but you shouldn't really need to.
    Rory

  4. #4
    Forum Contributor
    Join Date
    07-10-2020
    Location
    New Zealand
    MS-Off Ver
    365 personal
    Posts
    302

    Re: Code to Mimic On Activate

    Hi
    When I ran the suggested Code as a separate Macro with a Line of Code Debug.print ActiveSheet.Name between each Line of Code got the following output

    Macro Code

    Please Login or Register  to view this content.
    When Starting the Macro from the PayrollCalc Sheet:
    PayrollCalc
    PayrollCalc
    PayrollCalc
    PayrollCalc


    When Starting eth Macro from the Summary PayrollCalc Sheet :
    Summary PayrollCalc
    Summary PayrollCalc
    Summary PayrollCalc
    PayrollCalc

    How does the code need to be changed?

    Thanks

    Allister
    @Maniacb
    Last edited by AllisterB; 05-13-2021 at 01:01 PM.

+ 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] Deactivate code, print and activate code again
    By Immortal2014 in forum Excel General
    Replies: 4
    Last Post: 11-28-2016, 03:01 AM
  2. Code to Activate a sheet 1 [IF] Userform box is "X" if not Activate Sheet 2
    By Invicta084 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 02-07-2014, 08:50 AM
  3. [SOLVED] VBA code for pivots to mimic each other (Excel 2003)
    By paulary30 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-12-2013, 08:39 AM
  4. Mimic Clicking Little X With Code
    By pavel3002 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-15-2011, 06:43 PM
  5. [SOLVED] Using code to mimic a find and replace
    By ST in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-30-2005, 08:06 AM
  6. [SOLVED] Code to mimic vlookup
    By Mark in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-30-2005, 01:06 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