ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Need to identify active worksheet in macro (https://www.excelbanter.com/excel-worksheet-functions/134544-need-identify-active-worksheet-macro.html)

MLK

Need to identify active worksheet in macro
 
Currently I have 10 pivot reports in one Excel spreadsheet. I built in one
macro to go through and format all 10 reports for printing at one time ...
with the first tab report being the last report that's formatted. The
problem is that if someone is on tab 4 and runs the macro, the macro does its
thing by formatting all reports however the person ends back up in tab 1
report. This will occur on all tabs.

Is there a way to tell in the macro which sheet the user ran the macro from
and take them right back to that same sheet?

Thanks, Mary-Lou

Paul B

Need to identify active worksheet in macro
 
MLK, try something like this

Dim CS As Worksheet
Set CS = ActiveSheet
'Your code here
CS.Select

--
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

"MLK" wrote in message
...
Currently I have 10 pivot reports in one Excel spreadsheet. I built in
one
macro to go through and format all 10 reports for printing at one time ...
with the first tab report being the last report that's formatted. The
problem is that if someone is on tab 4 and runs the macro, the macro does
its
thing by formatting all reports however the person ends back up in tab 1
report. This will occur on all tabs.

Is there a way to tell in the macro which sheet the user ran the macro
from
and take them right back to that same sheet?

Thanks, Mary-Lou





All times are GMT +1. The time now is 01:07 AM.

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