+ Reply to Thread
Results 1 to 4 of 4

Need to expand a macro to not run if worksheet is not visible

  1. #1
    Registered User
    Join Date
    08-26-2012
    Location
    Hamilton, New Zealand
    MS-Off Ver
    Excel 2010
    Posts
    3

    Need to expand a macro to not run if worksheet is not visible

    I have the following macros to open or close worksheets. The workbook will be used by a number of users and if the worksheets are closed and the macro button is selected and error appears as below? What statement should I include in this macro so it doesn't error if the worksheets are not visible. Also if the macro is untidy is there a more efficient way to write it. I image I need to do some sort of If statement but not sure what to write.

    Please Login or Register  to view this content.
    I get a Run-time error '1004' Select method of sheets class failed if the

    Thanks
    Last edited by JBeaucaire; 09-25-2012 at 12:43 AM. Reason: Added code tags, as per forum rules. Don't forget!

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Need to expand a macro to not run if worksheet is not visible

    Maybe this instead to run through each sheet individually rather than trying to "select a hidden sheet" which is not possible.
    Please Login or Register  to view this content.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    08-26-2012
    Location
    Hamilton, New Zealand
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Need to expand a macro to not run if worksheet is not visible

    Thanks Jerrry

    A much better macro

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Need to expand a macro to not run if worksheet is not visible

    If that resolves your need, please select Thread Tools from the menu above and mark the thread as solved. Thanks.

+ 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