Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Sheet name problem

Use
lastsheet = activesheet

And this to select it for example
lastsheet.select

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



"NathanG" wrote in message ...
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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default 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" wrote in message ...
Use
lastsheet = activesheet

And this to select it for example
lastsheet.select

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



"NathanG" wrote in message ...
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





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default Sheet name problem

Try:

Dim wsLastSheet As Worksheet

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



In article ,
"NathanG" 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.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default 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" wrote in message
...
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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem Sheet on its way fselker Excel Discussion (Misc queries) 5 February 20th 06 07:21 PM
Problem pasting a row from a hidden sheet to the first free row on another visible sheet Didier Poskin Excel Programming 2 January 10th 04 01:18 AM
Copy Sheet Problem Jim[_34_] Excel Programming 8 January 2nd 04 11:50 AM
Problem in activating a sheet Neeleshwar Thakur Excel Programming 1 December 18th 03 12:43 PM
Sheet Update Problem Gary Desroches[_2_] Excel Programming 1 October 5th 03 10:38 PM


All times are GMT +1. The time now is 02:28 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"