Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 53
Default Returning to the last sheet used

I might be trying to simplify this too much and that may be why it isn't
working. (Rewording my question)

I have a macro that manipulates data on a worksheet when a button is pushed
on that worksheet.

In that macro I want a line to store the worksheet name in case I need to go
back and change the data just entered.
Here is the code that is trying to store the sheet name:
LastCust = ActiveSheet.Name ' Stores the Active Sheets name in a
variable called LastCust

On another sheet (an Index Sheet) I have a button that I want to be able to
push if I need to change the last transaction I made on the customer's
sheet. Here is the code to recall that sheet and make it the active sheet
again (code in a different macro but in the same workbook). (It isn't
working):
Worksheets(LastCust).Activate ' Activates the worksheet that was saved
using the variable LastCust

Once activated (or selected) I can make the code make the changes I need.
I just can't get the proevious sheet activated again.

I'd like to be able to do this as simply as possible without using user
forms, and special add-ins and functions if possible.

As always, Thanks
Jonco


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 709
Default Returning to the last sheet used

jonco, Above you code try and put
Public LastCust As String


--
Paul B
Always backup your data before trying something new
Please post any response to the newsgroups so others can benefit from it
Feedback on answers is always appreciated!
Using Excel 2002 & 2003

"jonco" wrote in message
et...
I might be trying to simplify this too much and that may be why it isn't
working. (Rewording my question)

I have a macro that manipulates data on a worksheet when a button is

pushed
on that worksheet.

In that macro I want a line to store the worksheet name in case I need to

go
back and change the data just entered.
Here is the code that is trying to store the sheet name:
LastCust = ActiveSheet.Name ' Stores the Active Sheets name in a
variable called LastCust

On another sheet (an Index Sheet) I have a button that I want to be able

to
push if I need to change the last transaction I made on the customer's
sheet. Here is the code to recall that sheet and make it the active sheet
again (code in a different macro but in the same workbook). (It isn't
working):
Worksheets(LastCust).Activate ' Activates the worksheet that was saved
using the variable LastCust

Once activated (or selected) I can make the code make the changes I need.
I just can't get the proevious sheet activated again.

I'd like to be able to do this as simply as possible without using user
forms, and special add-ins and functions if possible.

As always, Thanks
Jonco




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 53
Default Returning to the last sheet used

I get a runtime error 9 - Subscript out of range on this line:
Worksheets(LastCust).Activate (This is the macro that opens the last sheet
up)

Jonco

Paul B wrote:
jonco, Above you code try and put
Public LastCust As String

"jonco" wrote in message
et...
I might be trying to simplify this too much and that may be why it isn't
working. (Rewording my question)

I have a macro that manipulates data on a worksheet when a button is
pushed on that worksheet.

In that macro I want a line to store the worksheet name in case I need to
go back and change the data just entered.
Here is the code that is trying to store the sheet name:
LastCust = ActiveSheet.Name ' Stores the Active Sheets name in a
variable called LastCust

On another sheet (an Index Sheet) I have a button that I want to be able
to push if I need to change the last transaction I made on the customer's
sheet. Here is the code to recall that sheet and make it the active sheet
again (code in a different macro but in the same workbook). (It isn't
working):
Worksheets(LastCust).Activate ' Activates the worksheet that was saved
using the variable LastCust

Once activated (or selected) I can make the code make the changes I need.
I just can't get the proevious sheet activated again.

I'd like to be able to do this as simply as possible without using user
forms, and special add-ins and functions if possible.

As always, Thanks
Jonco



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Returning to the last sheet used

this line

Public LastCust As String


needs to be at the top of a general module (insert=Module) and only
there.

--
Regards,
Tom Ogilvy


"jonco" wrote in message
et...
I get a runtime error 9 - Subscript out of range on this line:
Worksheets(LastCust).Activate (This is the macro that opens the last
sheet up)

Jonco

Paul B wrote:
jonco, Above you code try and put
Public LastCust As String

"jonco" wrote in message
et...
I might be trying to simplify this too much and that may be why it isn't
working. (Rewording my question)

I have a macro that manipulates data on a worksheet when a button is
pushed on that worksheet.

In that macro I want a line to store the worksheet name in case I need to
go back and change the data just entered.
Here is the code that is trying to store the sheet name:
LastCust = ActiveSheet.Name ' Stores the Active Sheets name in a
variable called LastCust

On another sheet (an Index Sheet) I have a button that I want to be able
to push if I need to change the last transaction I made on the customer's
sheet. Here is the code to recall that sheet and make it the active
sheet again (code in a different macro but in the same workbook). (It
isn't working):
Worksheets(LastCust).Activate ' Activates the worksheet that was saved
using the variable LastCust

Once activated (or selected) I can make the code make the changes I need.
I just can't get the proevious sheet activated again.

I'd like to be able to do this as simply as possible without using user
forms, and special add-ins and functions if possible.

As always, Thanks
Jonco





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 53
Default Returning to the last sheet used

Tom (and others),
Thanks, That was the tip I needed. I'm really grateful for all the help I
get here. You guys really know your stuff.

Jonco


"Tom Ogilvy" wrote in message
...
this line

Public LastCust As String


needs to be at the top of a general module (insert=Module) and only
there.

--
Regards,
Tom Ogilvy


"jonco" wrote in message
et...
I get a runtime error 9 - Subscript out of range on this line:
Worksheets(LastCust).Activate (This is the macro that opens the last
sheet up)

Jonco

Paul B wrote:
jonco, Above you code try and put
Public LastCust As String

"jonco" wrote in message
et...
I might be trying to simplify this too much and that may be why it isn't
working. (Rewording my question)

I have a macro that manipulates data on a worksheet when a button is
pushed on that worksheet.

In that macro I want a line to store the worksheet name in case I need
to go back and change the data just entered.
Here is the code that is trying to store the sheet name:
LastCust = ActiveSheet.Name ' Stores the Active Sheets name in a
variable called LastCust

On another sheet (an Index Sheet) I have a button that I want to be able
to push if I need to change the last transaction I made on the
customer's sheet. Here is the code to recall that sheet and make it the
active sheet again (code in a different macro but in the same workbook).
(It isn't working):
Worksheets(LastCust).Activate ' Activates the worksheet that was saved
using the variable LastCust

Once activated (or selected) I can make the code make the changes I
need. I just can't get the proevious sheet activated again.

I'd like to be able to do this as simply as possible without using user
forms, and special add-ins and functions if possible.

As always, Thanks
Jonco









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
Max Value Across Worksheets Returning Sheet Name [email protected] Excel Discussion (Misc queries) 2 June 13th 07 01:01 PM
Returning contents of a cell in another sheet in same workbook Annette[_2_] Excel Discussion (Misc queries) 1 March 14th 07 04:04 PM
Returning data to Excel sheet from MS query SNB Excel Discussion (Misc queries) 0 April 27th 05 01:27 AM
Newbie Question: Returning the value from a cell on another sheet SmilingPolitely[_2_] Excel Programming 4 July 14th 04 01:23 PM
returning Excel sheet with ASP Holli Excel Programming 1 April 17th 04 07:38 PM


All times are GMT +1. The time now is 06:20 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"