+ Reply to Thread
Results 1 to 7 of 7

Passing variables

Hybrid View

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

    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
    174
    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 :
    Private Sub Workbook_SheetDeactivate(ByVal Sh As Object)
    a = Sh.Name
    End Sub
    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.
    Public a
    Sub test()
    Sheets(a).Activate
    End Sub
    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
    174

    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
    174
    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

+ 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