ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Relative return to original worksheet in middle of macro (https://www.excelbanter.com/excel-programming/363136-relative-return-original-worksheet-middle-macro.html)

[email protected]

Relative return to original worksheet in middle of macro
 
Hi -

I'm making a macro that is used for many workbooks that will all have a
different worksheet names (sheet, sheet2, etc...). The macro creates
two new worksheets then it needs to return to the original worksheet to
perform an action. So right in the middle of the macro, it needs to
return to the original worksheet but that worksheet will always have a
different name - is there anyway to do that? I couldn't find it or
figure it out - I thought there was just some easy command, maybe?

Thanks
A


Tom Ogilvy

Relative return to original worksheet in middle of macro
 
Dim sh as Worksheet
set sh = Activesheet

. . .

' now return to original sheet
sh.Activate

--
Regards,
Tom Ogilvy


" wrote:

Hi -

I'm making a macro that is used for many workbooks that will all have a
different worksheet names (sheet, sheet2, etc...). The macro creates
two new worksheets then it needs to return to the original worksheet to
perform an action. So right in the middle of the macro, it needs to
return to the original worksheet but that worksheet will always have a
different name - is there anyway to do that? I couldn't find it or
figure it out - I thought there was just some easy command, maybe?

Thanks
A



[email protected]

Relative return to original worksheet in middle of macro
 
Thanks much.


Tom Ogilvy wrote:
Dim sh as Worksheet
set sh = Activesheet

. . .

' now return to original sheet
sh.Activate

--
Regards,
Tom Ogilvy


" wrote:

Hi -

I'm making a macro that is used for many workbooks that will all have a
different worksheet names (sheet, sheet2, etc...). The macro creates
two new worksheets then it needs to return to the original worksheet to
perform an action. So right in the middle of the macro, it needs to
return to the original worksheet but that worksheet will always have a
different name - is there anyway to do that? I couldn't find it or
figure it out - I thought there was just some easy command, maybe?

Thanks
A





All times are GMT +1. The time now is 04:08 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com