+ Reply to Thread
Results 1 to 8 of 8

If then skip macro

  1. #1
    Registered User
    Join Date
    10-22-2013
    Location
    Iowa
    MS-Off Ver
    Excel 2010
    Posts
    36

    If then skip macro

    I have a macro i have worked on that is pretty basic, it hides the listed sheets within the macro. An issue I ahve run across is that if one of the sheets are already closed, then it will throw an error. I realize that I need to use boolean logic(which I don't have a firm understanding of), and created a section that states "if already hidden, then skip to next sheet". The macro is listed below. I'm not an expert with scripting as i have been self taught in what little I have done so far, so any nudge in the right direction would be greatly apreciated.

    Please Login or Register  to view this content.
    Last edited by mdoverl; 10-22-2013 at 01:51 PM.

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

    Re: If then skip macro

    Hi, mdoverl,

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here



    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)+

    Ciao,
    Holger
    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

  3. #3
    Registered User
    Join Date
    10-22-2013
    Location
    Iowa
    MS-Off Ver
    Excel 2010
    Posts
    36

    Re: If then skip macro

    Sorry HaHoBe, it has been fixed

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

    Re: If then skip macro

    Hi, mdoverl,

    you could reduce the code like
    Please Login or Register  to view this content.
    but I think it would be a better way to use a Select Case and name the sheets to be visible at the end (one sheet must remain visible in the workbook):
    Please Login or Register  to view this content.
    Here Master and Instruction would remain visible while all other sheets (no matter how many) would be hidden.

    Ciao,
    Holger

  5. #5
    Registered User
    Join Date
    10-22-2013
    Location
    Iowa
    MS-Off Ver
    Excel 2010
    Posts
    36

    Re: If then skip macro

    The reason I have chosen to name which sheets to hide is becuase at the moment there is abotu 12 sheets that I want to always be visible. There is a contents sheet with buttons to all sheets for navigation. But I think you have given a pretty good idea on how to aproach it

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

    Re: If then skip macro

    Hi, mdoverl,

    you may enter the names like shown here or work with an extra sheet which holds a list of the names and their status which could be worked on in a loop (sheet should be hidden as well).

    Ciao,
    Holger

  7. #7
    Registered User
    Join Date
    10-22-2013
    Location
    Iowa
    MS-Off Ver
    Excel 2010
    Posts
    36

    Re: If then skip macro

    Oh I see, I completely understand the scripting now, thank you HaHoBe, will post later with my success story

  8. #8
    Registered User
    Join Date
    10-22-2013
    Location
    Iowa
    MS-Off Ver
    Excel 2010
    Posts
    36

    Re: If then skip macro

    the script worked like a charm, thank you very much HaHoBe, below is the finished scripted

    Please Login or Register  to view this content.
    I'm sure you can tell, but I'm working on character sheets and adding rulebooks from various RPG games. Trying to make an all in one source for my players, or future players I should say.

+ 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. macro to skip over to the next cell
    By Nubstar in forum Excel General
    Replies: 1
    Last Post: 10-31-2012, 08:41 AM
  2. How do I skip part of a macro?
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-26-2008, 06:39 PM
  3. [SOLVED] If cell is empty then run macro otherwise skip this macro
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-12-2006, 11:00 AM
  4. [SOLVED] IF-THEN to skip portion of macro
    By excelnut1954 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-23-2005, 12:15 PM
  5. Sheets Skip Macro
    By NICK in forum Excel General
    Replies: 2
    Last Post: 02-11-2005, 04:06 AM

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