+ Reply to Thread
Results 1 to 9 of 9

How to prevent macro from running in unintended workbooks

  1. #1
    Registered User
    Join Date
    06-16-2012
    Location
    Wisconsin, USA
    MS-Off Ver
    Excel 2010
    Posts
    24

    How to prevent macro from running in unintended workbooks

    As long as I only have one workbook open, this macro works great, but every time this macro runs while I have other work books open, it runs in the current work book that is open, failing to do what it's intended to do, please see the below code.

    Also- if you can offer any advice to help make this code more solid I would appreciate it. Thank you.
    (I just added the "sheets("update").Select on the 1st line hoping that will solve the issue but I can not check to see if it's going to work becuse I am not at work right now, so I dont know if that will help.)


    Please Login or Register  to view this content.
    Last edited by siray13; 07-07-2012 at 07:58 AM.

  2. #2
    Forum Guru
    Join Date
    03-12-2010
    Location
    Canada
    MS-Off Ver
    2010 and 2013
    Posts
    4,418

    Re: How to prevent macro from running in unintended workbooks

    Please use code tags are around your code and provide us with a dummy workbook so we can test the resulting code (unless you want to debug).

    Here is what I have so far (naturally... untested):

    Please Login or Register  to view this content.
    Q1) what is setDate and TimeUp? Should they be the same thing?
    Please consider:

    Thanking those who helped you. Click the star icon in the lower left part of the contributor's post and add Reputation.
    Cleaning up when you're done. Mark your thread [SOLVED] if you received your answer.

  3. #3
    Registered User
    Join Date
    06-16-2012
    Location
    Wisconsin, USA
    MS-Off Ver
    Excel 2010
    Posts
    24

    Re: How to prevent macro from running in unintended workbooks

    The TimeUp refers to the following code, its the same thing. This is to keep a clock active that will show how long it has been since the sheet has been updated.

    Please Login or Register  to view this content.
    Last edited by siray13; 07-07-2012 at 07:59 AM.

  4. #4
    Forum Guru
    Join Date
    03-12-2010
    Location
    Canada
    MS-Off Ver
    2010 and 2013
    Posts
    4,418

    Re: How to prevent macro from running in unintended workbooks

    OK. Let me know if you have any questions or problems. If not, then please mark the thread as solved.

  5. #5
    Registered User
    Join Date
    06-16-2012
    Location
    Wisconsin, USA
    MS-Off Ver
    Excel 2010
    Posts
    24

    Re: How to prevent macro from running in unintended workbooks

    For this line

    Please Login or Register  to view this content.
    how do I get it to "paste" the values only?

    This is copying a formula which is for a hyperlink and is used for the email address, the address is pulled from B2:B941 and I have trouble getting the emails to send with anything other than plain text.

    Thanks for your help on this.
    Last edited by siray13; 07-07-2012 at 08:12 AM.

  6. #6
    Forum Guru
    Join Date
    03-12-2010
    Location
    Canada
    MS-Off Ver
    2010 and 2013
    Posts
    4,418

    Re: How to prevent macro from running in unintended workbooks

    Try this:

    Please Login or Register  to view this content.

  7. #7
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: How to prevent macro from running in unintended workbooks

    Siray, you need to add code tags to your first post and use Code Tags not HTML Tags. This is explained if you bother to read theForum Rules
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  8. #8
    Registered User
    Join Date
    06-16-2012
    Location
    Wisconsin, USA
    MS-Off Ver
    Excel 2010
    Posts
    24

    Re: How to prevent macro from running in unintended workbooks

    Works perfect thank you for your help!!

  9. #9
    Forum Guru
    Join Date
    03-12-2010
    Location
    Canada
    MS-Off Ver
    2010 and 2013
    Posts
    4,418

    Re: How to prevent macro from running in unintended workbooks

    Thanks for the feedback and marking the thread as Solved.

    Good luck.

    abousetta

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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