+ Reply to Thread
Results 1 to 6 of 6

Active Sheet not automatically running macro

  1. #1
    Forum Contributor
    Join Date
    01-21-2013
    Location
    Aberdeen, Scotland
    MS-Off Ver
    Excel 2007
    Posts
    258

    Active Sheet not automatically running macro

    Hey,

    I have a couple of macro's that run when I active specific sheets. On my main sheet there are hyperlinks to various other hidden sheets. I use the below code to allow them to activate when I click the hyperlink.

    Please Login or Register  to view this content.
    When Clicked it opens the sheet and then this Macro should run

    Please Login or Register  to view this content.
    But It doesn't. Which is my problem. It used to run the code before I decided it would be neater to hide all my sheets (there are lots of them, all based on a template that has this code embedded in it)
    So it must be something about having them activated using the first macro. Is there anything I could add to the code that would ensure it runs?

    Thanks in advance for any help.

    R

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Active Sheet not automatically running macro

    Hi,

    Difficult to comment without seeing the problem in context. Any chance you could upload the workbook. At first glance I can see little awry.

    On an associated note, although I don't think it's associated with your problem, I see that you are using the FollowHyperlink event.
    Is the hyperlink needed for its prime purpose which is to position the cursor elsewhere in the workbook or are you just using it to trigger the macro?

    I ask because I recently encountered a problem with users who had both Excel for Windows and Excel for Mac and when the Mac users came to click a cell which had a hyperlink in much the same way as yours, then the macro wouldn't work. Can't remember the exact details now but It took me a while to figure it out and eventually had to write a separate procedure for anyone who happened to be using a Mac.

    I found it odd that the Follow Hyperlink code had been used at all since it wasn't used for its prime purpose. The most common way to trigger a macro as you are doing, assuming the hyperlink is not relevant, is a simple Sheet Change or Sheet Selection Change event.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Active Sheet not automatically running macro

    You disable events before the target.follow command, which will disable the worksheet_activate module.

    I would suggest:
    putting the worksheet_activate code in a separate sub, perhaps "Sub MyActivate_Macro()" then in your worksheet_Activate sub and after the target.follow command you could put "call MyActivate_Macro"

  4. #4
    Forum Contributor
    Join Date
    01-21-2013
    Location
    Aberdeen, Scotland
    MS-Off Ver
    Excel 2007
    Posts
    258

    Re: Active Sheet not automatically running macro

    Please Login or Register  to view this content.
    Tried changing it to this, so it's actually activating the sheet. But to no avail

  5. #5
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Active Sheet not automatically running macro

    Enableevents = false !!!!!

  6. #6
    Forum Contributor
    Join Date
    01-21-2013
    Location
    Aberdeen, Scotland
    MS-Off Ver
    Excel 2007
    Posts
    258

    Re: Active Sheet not automatically running macro

    Yudlugar, well spotted.

    Getting rid of this line has solved my problem.
    Please Login or Register  to view this content.
    Thank you both for your help

+ 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. Select desired active cell after running the Macro
    By graiggoriz in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-24-2013, 07:38 AM
  2. [SOLVED] Macro running on active sheet instead of sheet defined in macro
    By davegscott in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-19-2013, 02:04 PM
  3. Macro to Print active sheet as PDF to Active workbook and customize name
    By Scott Taylor in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-17-2012, 08:52 PM
  4. 'Active' Cells Issue When Running Macro
    By JamieM in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-10-2007, 05:55 AM
  5. How to show the active cell after running a macro?
    By shellshock in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-01-2005, 07:18 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