+ Reply to Thread
Results 1 to 7 of 7

Relative Worksheet References To Visible Sheet Only (VBA)

  1. #1
    Registered User
    Join Date
    08-19-2015
    Location
    London, England
    MS-Off Ver
    365
    Posts
    67

    Relative Worksheet References To Visible Sheet Only (VBA)

    Hi there,

    I've been searching the internet for quit some time now, but I can't find the answer I'm looking for and now my hope is pinned on you guys ;-)

    I'm using the following code to refer to a previous sheet (which works great btw), but my problem lies in the fact that it doesn't skip hidden sheets.
    I would like the "PrevSheet" formula in sheet 3 to refer to sheet 1 instead of sheet 2 if sheet 2 is hidden.

    Please Login or Register  to view this content.
    I've tried several modifications already, but noob as I am, without succes.

    Many thanks in advance...
    Last edited by JBeaucaire; 08-24-2015 at 05:52 AM. Reason: Added missing CODE tags. Please read and follow the Forum Rules, link above in the menu bar. Thanks.

  2. #2
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: Relative Worksheet References To Visible Sheet Only (VBA)

    Hi blak9,
    maybe so
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    08-19-2015
    Location
    London, England
    MS-Off Ver
    365
    Posts
    67

    Re: Relative Worksheet References To Visible Sheet Only (VBA)

    Ni nilem,

    Thanks a million for your quick reply. It really does kinda work, however...

    These are the results when I hide sheet 3.

    Sheet 1 > A1: 10
    Sheet 2 > A1: =PrevSheet(A1)+1 returns 11
    Sheet 3 Hidden
    Sheet 4 > A1: =PrevSheet(A1)+1 returns 13

    But, (re)entering the value of 10 in Sheet 1 > A1 does give the proper result of
    Sheet 1 > A1: 10
    Sheet 2 > A1: =PrevSheet(A1)+1 returns 11
    Sheet 3 Hidden
    Sheet 4 > A1: =PrevSheet(A1)+1 returns 12

    Same thing when I unhide Sheet 3. The update of the other sheets occurs only when I reenter the value in Sheet 1 > A1.

    Is it possible to update the various sheets live, so that when I hide or unhide a particular sheet, the value of the other sheets change accordingly..?

    Thanks in advance...
    Last edited by blak9; 08-24-2015 at 06:51 AM.

  4. #4
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: Relative Worksheet References To Visible Sheet Only (VBA)

    your function is recalculated for any change in the worksheet
    Try to hide Sheet3 and change the value of any cell on the active worksheet, you'll see that it works.
    Or try to add this code in the ThisWorkBook module (not sure that's a good idea)
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    08-19-2015
    Location
    London, England
    MS-Off Ver
    365
    Posts
    67

    Re: Relative Worksheet References To Visible Sheet Only (VBA)

    Wow, thanks..!
    I didn't know that 'any change' in my workbook would update the specified values. I can truly live with that, so that in itself solves my challenge.
    But, ofcourse I had to try your second suggestion (Private Sub routine), which is beyond awesome and works like a charm...! :-) Just for my understanding, why would you think that's not a good idea though..?

  6. #6
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: Relative Worksheet References To Visible Sheet Only (VBA)

    if you have a lots of formulas in the worksheet, all of these formulas will be recalculated. It may take a long time.
    Although you can use only one cell for example, something like
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    08-19-2015
    Location
    London, England
    MS-Off Ver
    365
    Posts
    67

    Re: Relative Worksheet References To Visible Sheet Only (VBA)

    Thanks for the additional option.
    Just tested both option, and since speed isn't really an issue I'll stick to the former one...

    I guess we can close this thread as SOLVED. Thanks again for helping me out...

+ 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: 2
    Last Post: 12-06-2013, 03:18 PM
  2. [SOLVED] Macro help to move data from one sheet to another using relative references
    By JPayne@nbri in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-25-2013, 11:28 AM
  3. Replies: 3
    Last Post: 07-03-2012, 11:39 AM
  4. Relative Worksheet References
    By catccc in forum Excel General
    Replies: 1
    Last Post: 06-30-2010, 03:31 PM
  5. Replies: 3
    Last Post: 08-10-2009, 04:10 AM
  6. Replies: 4
    Last Post: 07-30-2008, 11:19 PM
  7. Copying relative worksheet references
    By di00721 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-05-2006, 07:09 PM
  8. [SOLVED] relative sheet references ala sheet(-1)!B11 so I can copy a sheet.
    By RonMc5 in forum Excel General
    Replies: 9
    Last Post: 02-02-2005, 09:06 PM

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