Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Lee Lee is offline
external usenet poster
 
Posts: 33
Default Moving Between Worksheets

I have a workbook that has many worksheets. Macros are
attached to each of these that extract data to a temporary
worksheet, save the file as a csv, clears the temp file
then returns to the worksheet it came from. During
execution the temp file becomes the active worksheet so
the user can see the data that is being exported

The problem is that the names of the worksheets are
written within the macros and if someone changes the name
of the sheet, it exports the data but gets hung up during
exit since it cannot find the worksheet to return to.

How can I store the name of a sheet as a variable to be
used during macro execution, so the user returns to the
sheet they initiated the macro from no matter what they
may have renamed the sheet to? I would like to eliminate
the sheet names from the code so the user can rename them
as necessary.

Any help is appreciated.

Lee
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Moving Between Worksheets

Lee,

Use the worksheet codename rather than it's Excel name. This is of the
format

Sheet1.Activate

rather than Worksheets("Sheet1").Activate

The codenmae is the first name in the name pairs in the VBE explorer window.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Lee" wrote in message
...
I have a workbook that has many worksheets. Macros are
attached to each of these that extract data to a temporary
worksheet, save the file as a csv, clears the temp file
then returns to the worksheet it came from. During
execution the temp file becomes the active worksheet so
the user can see the data that is being exported

The problem is that the names of the worksheets are
written within the macros and if someone changes the name
of the sheet, it exports the data but gets hung up during
exit since it cannot find the worksheet to return to.

How can I store the name of a sheet as a variable to be
used during macro execution, so the user returns to the
sheet they initiated the macro from no matter what they
may have renamed the sheet to? I would like to eliminate
the sheet names from the code so the user can rename them
as necessary.

Any help is appreciated.

Lee



  #3   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default Moving Between Worksheets

Bob,

Thanks !!!

Lee

-----Original Message-----
Lee,

Use the worksheet codename rather than it's Excel name.

This is of the
format

Sheet1.Activate

rather than Worksheets("Sheet1").Activate

The codenmae is the first name in the name pairs in the

VBE explorer window.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Lee" wrote in

message
...
I have a workbook that has many worksheets. Macros are
attached to each of these that extract data to a

temporary
worksheet, save the file as a csv, clears the temp file
then returns to the worksheet it came from. During
execution the temp file becomes the active worksheet so
the user can see the data that is being exported

The problem is that the names of the worksheets are
written within the macros and if someone changes the

name
of the sheet, it exports the data but gets hung up

during
exit since it cannot find the worksheet to return to.

How can I store the name of a sheet as a variable to be
used during macro execution, so the user returns to the
sheet they initiated the macro from no matter what they
may have renamed the sheet to? I would like to

eliminate
the sheet names from the code so the user can rename

them
as necessary.

Any help is appreciated.

Lee



.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Moving Between Worksheets

Dim sh as Worksheet
set sh = Activesheet




sh.Activate

--
Regards,
Tom Ogilvy

"Lee" wrote in message
...
I have a workbook that has many worksheets. Macros are
attached to each of these that extract data to a temporary
worksheet, save the file as a csv, clears the temp file
then returns to the worksheet it came from. During
execution the temp file becomes the active worksheet so
the user can see the data that is being exported

The problem is that the names of the worksheets are
written within the macros and if someone changes the name
of the sheet, it exports the data but gets hung up during
exit since it cannot find the worksheet to return to.

How can I store the name of a sheet as a variable to be
used during macro execution, so the user returns to the
sheet they initiated the macro from no matter what they
may have renamed the sheet to? I would like to eliminate
the sheet names from the code so the user can rename them
as necessary.

Any help is appreciated.

Lee



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
moving worksheets house boy Excel Discussion (Misc queries) 2 July 31st 08 03:22 AM
Moving Worksheets using VB Marie Bayes Excel Discussion (Misc queries) 4 January 18th 07 03:00 PM
Moving all worksheets jerredjohnson Excel Discussion (Misc queries) 1 June 15th 06 06:01 PM
Moving Between Worksheets wormdazzler Excel Discussion (Misc queries) 3 October 27th 05 04:57 PM
moving a row between worksheets Amit New Users to Excel 2 January 26th 05 02:25 PM


All times are GMT +1. The time now is 09:10 AM.

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

About Us

"It's about Microsoft Excel"