+ Reply to Thread
Results 1 to 4 of 4

Exiting a macro if not physically on a certain worksheet

  1. #1
    Registered User
    Join Date
    06-04-2010
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    53

    Exiting a macro if not physically on a certain worksheet

    Hi Guys,
    I have set up an Excel workbook that contains several pages to run a macro on a specific page every 5 minutes. If I am manually looking at another page when the macro in question runs the worksheet flashes up an error as I am not on that specific page.

    I would very much like the macro NOT to run if I am looking at another page. Is there a way of exiting the macro in question if that specific page is not open in the worksheet.

    Kind of like If the sheet1 is not being viewed – exit sub.

    Probably a very simple answer – many thanks in advance,

    John
    Last edited by AliJay; 12-31-2012 at 06:54 AM. Reason: Solved

  2. #2
    Forum Expert
    Join Date
    07-16-2010
    Location
    Northumberland, UK
    MS-Off Ver
    Excel 2007 (home), Excel 2010 (work)
    Posts
    3,054

    Re: Exiting a macro if not physically on a certain worksheet

    Yep,

    Please Login or Register  to view this content.
    Should do the trick.

  3. #3
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Exiting a macro if not physically on a certain worksheet

    Hi, John,

    maybe a simple If-Statement could be enough:
    Please Login or Register  to view this content.
    Ciao,
    Holger
    Last edited by HaHoBe; 12-31-2012 at 06:55 AM. Reason: typos :(
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  4. #4
    Registered User
    Join Date
    06-04-2010
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    53

    Re: Exiting a macro if not physically on a certain worksheet

    Thank you both.

    A VERY Happy New Year to

+ 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