ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Help with macro (https://www.excelbanter.com/excel-discussion-misc-queries/150204-help-macro.html)

Tom

Help with macro
 
The last line of my code reads, "Selection.End(xlDown).Select", which is my
reference position on the spreadsheet. Then the macro carries out other
tasks moving the active cell elsewhere. How can I get back to my reference
position? I can't use define to fix that position as this location is
different when the macro is used on other spreadsheets. Thanks for any help.

TIA
Tom



Bernie Deitrick

Help with macro
 
Tom,

Dim myOrigSelection As Range


Set myOrigSelection = Selection

'Other Code

'To go back
myOrigSelection.Select

HTH,
Bernie
MS Excel MVP


"Tom" wrote in message
...
The last line of my code reads, "Selection.End(xlDown).Select", which is
my reference position on the spreadsheet. Then the macro carries out other
tasks moving the active cell elsewhere. How can I get back to my reference
position? I can't use define to fix that position as this location is
different when the macro is used on other spreadsheets. Thanks for any
help.

TIA
Tom





Dave Peterson

Help with macro
 
Dim ActCell as Range
'start by saving the current activecell
set actcell = activecell
'do as much as you want
'go back to that original activecell
application.goto actcell ', scroll:=true

Tom wrote:

The last line of my code reads, "Selection.End(xlDown).Select", which is my
reference position on the spreadsheet. Then the macro carries out other
tasks moving the active cell elsewhere. How can I get back to my reference
position? I can't use define to fix that position as this location is
different when the macro is used on other spreadsheets. Thanks for any help.

TIA
Tom


--

Dave Peterson

Tom

Help with macro
 
My thanks to Bernie and Dave. Your assistance is much appreciated.

Tom

"Tom" wrote in message
...
The last line of my code reads, "Selection.End(xlDown).Select", which is
my reference position on the spreadsheet. Then the macro carries out other
tasks moving the active cell elsewhere. How can I get back to my reference
position? I can't use define to fix that position as this location is
different when the macro is used on other spreadsheets. Thanks for any
help.

TIA
Tom






All times are GMT +1. The time now is 05:48 AM.

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