+ Reply to Thread
Results 1 to 2 of 2

Simple VBA question (?)

  1. #1
    Registered User
    Join Date
    03-26-2005
    Location
    Haarlem, the Netherlands
    MS-Off Ver
    Excel 2003, SP3
    Posts
    13

    Simple VBA question (?)

    Hi all, probably quite simple question, but I can't find the answer .....

    In my Excel-application 4 pages (worksheets) exist: for example A,B,C and D
    Button on page A moves the user to page D
    A similar button on page B navigates user also to page D

    Now I wish to implement one button on page D "back" > it should move the user back to the originating page, i.e. where he began his journey. In some cases he should go back to A, but sometimes to B.
    How should Excel remember the starting page??

    I tried Dim blabla as Name; blabla = Active.Worksheet.Name > then navigate to page D, then return to blabla. But the only thing happening is lots of error messages.
    I presume the solution could be simple? I am very grateful with an answer!
    Thanks,
    Kees

  2. #2
    Jim Thomlinson
    Guest

    RE: Simple VBA question (?)

    Add this code to Thisworkbook (right click the excel icon next to file on the
    Menu bar and select view code)...

    Public wksLast As Worksheet

    Private Sub Workbook_SheetDeactivate(ByVal Sh As Object)
    Set wksLast = Sh
    End Sub

    Your Back code will look like this (placed in a sheet or standard code
    module)...

    Sub Back()
    ThisWorkbook.wksLast.Select
    End Sub

    --
    HTH...

    Jim Thomlinson


    "Kees Korver" wrote:

    >
    > Hi all, probably quite simple question, but I can't find the answer
    > .....
    >
    > In my Excel-application 4 pages (worksheets) exist: for example A,B,C
    > and D
    > Button on page A moves the user to page D
    > A similar button on page B navigates user also to page D
    >
    > Now I wish to implement one button on page D "back" > it should move
    > the user back to the originating page, i.e. where he began his journey.
    > In some cases he should go back to A, but sometimes to B.
    > How should Excel remember the starting page??
    >
    > I tried Dim blabla as Name; blabla = Active.Worksheet.Name > then
    > navigate to page D, then return to blabla. But the only thing happening
    > is lots of error messages.
    > I presume the solution could be simple? I am very grateful with an
    > answer!
    > Thanks,
    > Kees
    >
    >
    > --
    > Kees Korver
    > ------------------------------------------------------------------------
    > Kees Korver's Profile: http://www.excelforum.com/member.php...o&userid=21562
    > View this thread: http://www.excelforum.com/showthread...hreadid=558249
    >
    >


+ 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