+ Reply to Thread
Results 1 to 7 of 7

Need Code to Select Next Visible Sheet

  1. #1
    Forum Contributor
    Join Date
    01-04-2013
    Location
    Tampa, Florida
    MS-Off Ver
    Excel 2013
    Posts
    142

    Need Code to Select Next Visible Sheet

    Hi there,

    I would appreciate if anyone could provide me with a code to select the next visible sheet. ActiveSheet.Next.Select doesn't work because there are a number of hidden sheets between the one I'm on and the one I want to get to.

    Thank you in advance.

  2. #2
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Need Code to Select Next Visible Sheet

    Try:

    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    01-04-2013
    Location
    Tampa, Florida
    MS-Off Ver
    Excel 2013
    Posts
    142

    Re: Need Code to Select Next Visible Sheet

    Hi stnkynts.

    That worked for what my request had asked. Thank you very much. I added your code to my existing code and it almost gets me to where I want. I thought I'd be able to get to the end on my own, but I'm running into a bit of trouble. From here I need to go over one more sheet to the right. This sheet is visible. Once on that sheet I want to select cell A1. I thought adding:

    Please Login or Register  to view this content.
    after the Next nsht line in your code would do that for me, but it doesn't seem to be working. Any suggestions?

    Thank you.

  4. #4
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Need Code to Select Next Visible Sheet

    The reason it may not be working is that you cannot select a hidden sheet. Im am confused on which sheet you are trying to activate relative to your active sheet. Do you want 2 visible sheets to the right?

  5. #5
    Forum Contributor
    Join Date
    01-04-2013
    Location
    Tampa, Florida
    MS-Off Ver
    Excel 2013
    Posts
    142

    Re: Need Code to Select Next Visible Sheet

    Okay, let me see if I can have this make sense. As an example, lets assume I have a workbook with 5 sheets. Sheet 1, Sheet 4 and Sheet 5 are visible. From Sheet 1 I need to get to Sheet 5. However, I can't have the code simply say select Sheet 5, because the next week I will have Sheet 1, Sheet 3, Sheet 4 and Sheet 5 visible and I will need to get from Sheet 1 to Sheet 4. So, from my active sheet I need to skip some hidden sheets, then select the 2nd visible sheet to the right. I hope that makes a bit more sense.

    Thank you for taking the time to work through this with me.

  6. #6
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Need Code to Select Next Visible Sheet

    Your explaination made perfect sense. It is refreshing to see someone able to clearly and concisely describe their situation. I have attached a reworked code that will select cell A1 of the second visible sheet (to the right of the active sheet). It should also handle any error handling that I could forsee coming up. If you have any questions on why or how the code is working let me know.

    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    01-04-2013
    Location
    Tampa, Florida
    MS-Off Ver
    Excel 2013
    Posts
    142

    Re: Need Code to Select Next Visible Sheet

    Worked like a charm! Thank you for your help.

+ 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