+ Reply to Thread
Results 1 to 4 of 4

VBA Return to Previous Page

  1. #1
    Registered User
    Join Date
    09-17-2013
    Location
    Michigan, USA
    MS-Off Ver
    Excel 2010
    Posts
    8

    Post VBA Return to Previous Page

    I have a button on my worksheet labled "Go Back". I need to assign a macro that will allow me to go back to the previous page. That previous page could be any of 8 different sheets in my workbook.

    I copied the following code from another workbook where it performed perfectly but I'm getting the error message: "run time error 9 - subscript out og range".
    I have no idea what I'm doing wrong - help!!

    Please Login or Register  to view this content.
    Moderator Note:

    Pls use code tags around your code next time as per forum rules.
    Last edited by Fotis1991; 09-19-2013 at 10:50 AM.

  2. #2
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: VBA Return to Previous Page

    I don't think you've copied the code correctly. You need to assign the variable lastsheet to something otherwise your goback macro will be the equivalent of:
    Please Login or Register  to view this content.
    I'd guess your missing something along the lines of:
    Please Login or Register  to view this content.
    Which should be stored in your "thisworkbook" object module.

  3. #3
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: VBA Return to Previous Page

    Copy this code and paste it into your general module...

    Please Login or Register  to view this content.
    For each worksheet in your workbook that you want to be able to go back to:
    • Right-click on the tab name...select: View Code
    • Copy the below code and paste it into the sheet's module
    Please Login or Register  to view this content.
    Now, whenever you run the GoBack program...the last deactivated sheet (containing that code) will be activated.

    Is that something you can work with?
    Ron
    Former Microsoft MVP - Excel (2006 - 2015)
    Click here to see the Forum Rules

  4. #4
    Registered User
    Join Date
    09-17-2013
    Location
    Michigan, USA
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: VBA Return to Previous Page

    That worked perfectly - thx!!!!

+ 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: 4
    Last Post: 07-02-2013, 02:41 PM
  2. How to copy format of previous printing-page and apply to the next printing-page?
    By Morrigan in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-25-2013, 06:01 PM
  3. Return to previous Page
    By Danielle123 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-09-2008, 01:31 PM
  4. [SOLVED] copy from previous page
    By Myriam in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-12-2005, 06:10 PM
  5. Accessing previous page
    By James Agostinho in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-02-2005, 03:06 PM

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