Consulting

Results 1 to 9 of 9

Thread: Solved: A kind of Back button in sheet for other sheets

  1. #1
    VBAX Regular
    Joined
    Dec 2008
    Posts
    86
    Location

    Solved: A kind of Back button in sheet for other sheets

    Dear Friends
    I need a lil help from you all. i have around 10 sheets and an 11th sheet called instructions. the sheet 'instructions' has all the info about the rest of the sheets(i.e like a help file). now i want a button to placed in each sheet which when clicked will take us to the 'instructions' sheet .till now no problem. now i want to give a 'back' button which will take it to the sheet from where it was revoked or activated. since this is dynamic so i cant give jus the sheet name.
    Any help is appreciated.
    Thanks in advance.
    Regards,
    Kishlaya

  2. #2
    Knowledge Base Approver VBAX Guru GTO's Avatar
    Joined
    Sep 2008
    Posts
    3,368
    Location
    Presuming an ActiveX button to be placed on "instructions", button code:
    [vba]
    Private Sub CommandButton1_Click()
    If Not strLastSheetName = vbNullString _
    Then ThisWorkbook.Worksheets(strLastSheetName).Activate
    End Sub
    [/vba]
    In the ThisWorkbook Module:
    [vba]Option Explicit

    Private Sub Workbook_SheetDeactivate(ByVal Sh As Object)
    strLastSheetName = Sh.Name
    End Sub[/vba]

    In a Standard Module:
    [vba]
    Option Explicit
    Public strLastSheetName As String
    [/vba]
    Since the Deactivate event should be the last thing to occur before activating the Instruction sheet, this would seem dependable to me.

    Hope that helps,

    Mark

  3. #3
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Here's a little Navigation Userform I use for larger workbooks. Search Navigate in the KB for some other items
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  4. #4
    VBAX Regular
    Joined
    Dec 2008
    Posts
    86
    Location

    Smile Thanks GTO

    Dear GTO
    Thanks a lot for your help, it works perfectly as desired.
    Regards,
    Kishlaya

  5. #5
    VBAX Regular
    Joined
    Dec 2008
    Posts
    86
    Location
    Dear Mdmackillop
    Thanks for the useful sheet for navigation, i want to know how despite being a iserform active i am still able to work with my sheets, i was trying to that for a long time.

  6. #6
    Knowledge Base Approver VBAX Guru GTO's Avatar
    Joined
    Sep 2008
    Posts
    3,368
    Location
    Hi Kishlaya,

    Very happy to help and you bet I'll be taking a gander at Malcom's wb later. It's nice to always be learning here, even with the amount of stuff that leaks out my brain nowadays...

    If solved, you could mark it as such under Thread Tools right above your first post. It just saves others from checking unnecessarily.

    Mark

  7. #7
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Quote Originally Posted by kishlaya
    Dear Mdmackillop
    Thanks for the useful sheet for navigation, i want to know how despite being a iserform active i am still able to work with my sheets, i was trying to that for a long time.
    That is a simple one; you need to open the form non-modal. The code for that is
    [VBA]
    Userform1.Show False
    [/VBA]
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  8. #8
    VBAX Mentor anandbohra's Avatar
    Joined
    May 2007
    Location
    Mumbai
    Posts
    313
    Location
    Dear mdmackillop

    in your given file navigate.xls

    U had already added the option button
    but if there is any method or something through which first we count the number of sheets in the file then add option button in the form & do your code.

    as u have given provision for 25 option button instead in form load it count no of sheets then option button controls should gets added to form automatically.

    JUST AN IMAGINATION OF MY MIND PL DO LET ME KNOW IF IT IS POSSIBLE OR NOT
    Always Mark your Thread as Solved the moment u got acceptable reply (located under Thread tools)
    Practice this & save time of others in thinking for unsolved thread

  9. #9
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    I'm giving it some thought. Should be possible.
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •