+ Reply to Thread
Results 1 to 7 of 7

Passing variables

  1. #1
    Forum Contributor
    Join Date
    05-07-2007
    Location
    Singapore
    MS-Off Ver
    2006/2016
    Posts
    170

    Red face Passing variables

    Ok lets say i have these pages in my workbook in this hierachical order:

    A -> either B or C -> D

    Every page starting from B onwards will have a back button to return to the previous page, so B/C will return to A.

    The question is if i'm at D, i expect the back button to take me to either B or C (depends on where i came from). Is there any way to do this?

    Background info:
    I have some knowledge in ASP so i understand querystrings. Is there any way i can send this data from B/C to D using one? If so, what language do i use?

  2. #2
    Forum Contributor
    Join Date
    05-07-2007
    Location
    Singapore
    MS-Off Ver
    2006/2016
    Posts
    170
    could someone help me with this please?

  3. #3
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile

    Good morning lordfa9

    Try putting this module into the ThisWorkbook module :
    Please Login or Register  to view this content.
    and put this code in a normal module. This is the code that your back button needs to link into. The above module just keeps a constant track of the last sheet.
    Please Login or Register  to view this content.
    This will only give you one level of going back - there will be no history.

    HTH

    DominicB
    Please familiarise yourself with the rules before posting. You can find them here.

  4. #4
    Forum Contributor
    Join Date
    05-07-2007
    Location
    Singapore
    MS-Off Ver
    2006/2016
    Posts
    170

    Question

    now i'm really confused... whats a ThisWorkbook Module?

  5. #5
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile

    Good morning lordfa9

    From Excel press Alt + F11 to go to the VBE.
    Find your project on the left hand side (eg, VBAProject (Book1.xls))
    Make sure it's expanded
    Double click on the ThisWorkbook text
    A new window should open on the right with two dropdowns at the top - General and Declarations. This is the ThisWorkbook module. Paste the code into here.

    HTH

    DominicB

  6. #6
    Forum Contributor
    Join Date
    05-07-2007
    Location
    Singapore
    MS-Off Ver
    2006/2016
    Posts
    170
    ok so the 1st part is a global (sheet-wide) macro

    how do i incoporate the 2nd part with a hyperlink?

    apologies if i dont understand, i thought it would be something like a querystring

  7. #7
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile

    Hi lordfa9

    You paste the second part into a regular module (from the VBE, Insert >Module). Then on every sheet, draw a button using the Forms toolbar, and assign each one to the macro I've called "test". Change the text on it to "Back" and each time you click on it it will take you to the previous sheet.

    See my example below.

    HTH

    DominicB
    Last edited by dominicb; 08-19-2008 at 04:29 AM.

+ 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