ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro to return to Current Sheet and Cell (https://www.excelbanter.com/excel-programming/341334-macro-return-current-sheet-cell.html)

Steve Klenner

Macro to return to Current Sheet and Cell
 
I have a macro that is used in several different areas in my workbook. The
macro changes values in several sheets from the sheet I'm on...and that all
works.

I'd like the macro to return me to whatever active sheet and cell I am
currently at....how can I accomplish this?

Thanks
Steve

--


----------------------------------------------------
This mailbox protected from junk email by MailFrontier Desktop
from MailFrontier, Inc. http://info.mailfrontier.com



William[_2_]

Macro to return to Current Sheet and Cell
 
'Place this at the start of your macro.....

Dim wb as workbook
Dim ws as worksheet
Dim c as range

set wb=activeworkbook
Set ws=wb.activesheet
set c=activecell

'Your code here

'Place this at the end of your macro.....
wb.activate
ws.select
c.select


--


XL2003
Regards

William



"Steve Klenner" wrote in message
...
I have a macro that is used in several different areas in my workbook. The
macro changes values in several sheets from the sheet I'm on...and that all
works.

I'd like the macro to return me to whatever active sheet and cell I am
currently at....how can I accomplish this?

Thanks
Steve

--


----------------------------------------------------
This mailbox protected from junk email by MailFrontier Desktop
from MailFrontier, Inc.
http://info.mailfrontier.com





Norman Jones

Macro to return to Current Sheet and Cell
 
Hi Steve:

In Addition to William's suggestion, try amending your code to avoid sheet
and range selections: most manipulation can be effected without making such
selections.

---
Regards,
Norman



"Steve Klenner" wrote in message
...
I have a macro that is used in several different areas in my workbook. The
macro changes values in several sheets from the sheet I'm on...and that all
works.

I'd like the macro to return me to whatever active sheet and cell I am
currently at....how can I accomplish this?

Thanks
Steve

--


----------------------------------------------------
This mailbox protected from junk email by MailFrontier Desktop
from MailFrontier, Inc. http://info.mailfrontier.com






All times are GMT +1. The time now is 05:19 PM.

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