+ Reply to Thread
Results 1 to 5 of 5

Sheet name problem

  1. #1
    NathanG
    Guest

    Sheet name problem

    Hi,

    I am developing a system where charts are used to display data. Two or more
    sheets within the system can go to the a chart. The problem is that I cannot
    get the back button to go to the previous sheet on which the user was on. I
    have copied the chart sheets to change the code but this does not solve the
    problem as new sheets are created with different sheet names so there is no
    way to no future sheet names. Is there a way of remembering the sheet before
    going to a chart and then being able to return the previous sheet.

    I dimed a variable called lastsheet and tried activesheet=lastsheet but I
    couldn't get the back button to recognise lastsheet as a sheetname.

    Many thanks for your help

    Nathan

  2. #2
    Ron de Bruin
    Guest

    Re: Sheet name problem

    Use
    lastsheet = activesheet

    And this to select it for example
    lastsheet.select

    --
    Regards Ron de Bruin
    http://www.rondebruin.nl



    "NathanG" <[email protected]> wrote in message news:[email protected]...
    > Hi,
    >
    > I am developing a system where charts are used to display data. Two or more
    > sheets within the system can go to the a chart. The problem is that I cannot
    > get the back button to go to the previous sheet on which the user was on. I
    > have copied the chart sheets to change the code but this does not solve the
    > problem as new sheets are created with different sheet names so there is no
    > way to no future sheet names. Is there a way of remembering the sheet before
    > going to a chart and then being able to return the previous sheet.
    >
    > I dimed a variable called lastsheet and tried activesheet=lastsheet but I
    > couldn't get the back button to recognise lastsheet as a sheetname.
    >
    > Many thanks for your help
    >
    > Nathan




  3. #3
    JE McGimpsey
    Guest

    Re: Sheet name problem

    Try:

    Dim wsLastSheet As Worksheet

    Set wsLastSheet = ActiveSheet
    'Do your chart stuff here
    wsLastSheet.Activate



    In article <[email protected]>,
    "NathanG" <[email protected]> wrote:

    > I am developing a system where charts are used to display data. Two or more
    > sheets within the system can go to the a chart. The problem is that I cannot
    > get the back button to go to the previous sheet on which the user was on. I
    > have copied the chart sheets to change the code but this does not solve the
    > problem as new sheets are created with different sheet names so there is no
    > way to no future sheet names. Is there a way of remembering the sheet before
    > going to a chart and then being able to return the previous sheet.
    >
    > I dimed a variable called lastsheet and tried activesheet=lastsheet but I
    > couldn't get the back button to recognise lastsheet as a sheetname.


  4. #4
    Bob Phillips
    Guest

    Re: Sheet name problem

    Nathan,

    Put this code in ThisWorkbook

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

    'This is workbook event code.
    'To input this code, right click on the Excel icon on the worksheet
    '(or next to the File menu if you maximise your workbooks),
    'select View Code from the menu, and paste the code


    and then in a general module add this code to support the Back function

    Public PrevSheet

    Sub Back()
    Application.EnableEvents = False
    PrevSheet.Activate
    Range("A1").Activate
    Set PrevSheet = ActiveSheet
    Application.EnableEvents = True
    End Sub


    --

    HTH

    RP
    (remove nothere from the email address if mailing direct)


    "NathanG" <[email protected]> wrote in message
    news:[email protected]...
    > Hi,
    >
    > I am developing a system where charts are used to display data. Two or

    more
    > sheets within the system can go to the a chart. The problem is that I

    cannot
    > get the back button to go to the previous sheet on which the user was on.

    I
    > have copied the chart sheets to change the code but this does not solve

    the
    > problem as new sheets are created with different sheet names so there is

    no
    > way to no future sheet names. Is there a way of remembering the sheet

    before
    > going to a chart and then being able to return the previous sheet.
    >
    > I dimed a variable called lastsheet and tried activesheet=lastsheet but I
    > couldn't get the back button to recognise lastsheet as a sheetname.
    >
    > Many thanks for your help
    >
    > Nathan




  5. #5
    Ron de Bruin
    Guest

    Re: Sheet name problem

    You see that I for get the "set "in my example before lastsheet
    See Bob's and J.E's reply


    --
    Regards Ron de Bruin
    http://www.rondebruin.nl



    "Ron de Bruin" <[email protected]> wrote in message news:[email protected]...
    > Use
    > lastsheet = activesheet
    >
    > And this to select it for example
    > lastsheet.select
    >
    > --
    > Regards Ron de Bruin
    > http://www.rondebruin.nl
    >
    >
    >
    > "NathanG" <[email protected]> wrote in message news:[email protected]...
    >> Hi,
    >>
    >> I am developing a system where charts are used to display data. Two or more
    >> sheets within the system can go to the a chart. The problem is that I cannot
    >> get the back button to go to the previous sheet on which the user was on. I
    >> have copied the chart sheets to change the code but this does not solve the
    >> problem as new sheets are created with different sheet names so there is no
    >> way to no future sheet names. Is there a way of remembering the sheet before
    >> going to a chart and then being able to return the previous sheet.
    >>
    >> I dimed a variable called lastsheet and tried activesheet=lastsheet but I
    >> couldn't get the back button to recognise lastsheet as a sheetname.
    >>
    >> Many thanks for your help
    >>
    >> Nathan

    >
    >




+ 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