+ Reply to Thread
Results 1 to 4 of 4

Restrict macro to one workbook

  1. #1
    Registered User
    Join Date
    07-10-2013
    Location
    UK
    MS-Off Ver
    Excel 2003
    Posts
    15

    Restrict macro to one workbook

    Hi.

    I'm in a situation where i have to have multiple excel workbooks open at the same time. For arguments sake i'll call them workbooks 1, 2 & 3.

    Workbook 1 has an ontime macro which displays a pop up at specific periods...a sample of the code is here:

    Please Login or Register  to view this content.
    Workbooks 2 & 3 are purely open for data entry whilst workbook 1 runs in the background, displaying the pop ups as and when if that makes sense.

    The problem i'm having is that if i enter a value in say cell D6 on workbook 2, the macro runs when i don't need it to!

    How do i restrict this macro to run purely on workbook 1 irrespective of the what other workbooks/sheets are open?

    I'm very new to macros and am a bit stumped!!!!

    Thanks in advance!!!

    Sam

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Restrict macro to one workbook

    Hello Sam,

    When you have more than one workbook, you need to make sure your macro code is referencing the correct workbook. The Range object will assume it is running in the active Workbook, unless you qualify it with the workbook and worksheet.

    The code below will use only "D6" on "Sheet1" of the workbook the macro is running in. Change "Sheet1" to worksheet name you are using.
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    07-10-2013
    Location
    UK
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: Restrict macro to one workbook

    Thank you very much!!
    works perfectly!!

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Restrict macro to one workbook

    Hello Sam,

    You're welcome.

+ 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. Replies: 0
    Last Post: 03-05-2013, 07:34 PM
  2. Replies: 0
    Last Post: 09-10-2012, 04:51 AM
  3. Restrict Access to Workbook
    By nguyeda in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-26-2009, 06:23 AM
  4. Restrict user from over-writing workbook
    By TwoyTaylor in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-24-2008, 11:23 PM
  5. [SOLVED] Protection - restrict macro exposure to the workbook, VBAProject
    By JB2005 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-15-2005, 09:45 AM

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