View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Rick Rothstein \(MVP - VB\)[_1910_] Rick Rothstein \(MVP - VB\)[_1910_] is offline
external usenet poster
 
Posts: 1
Default retain Selection

If all your work is being done on the same worksheet, this structure should
do what you want...

Sub YourMacro()
Selection.Name = "UniqueSavedName"
'
' <<<Your code goes here
'
Range("UniqueSavedName").Select
End Sub

If you are changing worksheets during your code, then this structure should
work...

Sub YourMacro()
Dim WS As Worksheet
Set WS = ActiveSheet
Selection.Name = "UniqueSavedName"
'
' <<<Your code goes here
'
WS.Select
Range("UniqueSavedName").Select
End Sub

Rick


"DrFear" wrote in message
...
I'm trying to restore the Selection that was in place at the time I
started a
routine that changes the selection during its run. In other words I want
something like

dim saveSel as Range
Set saveSel = Application.Selection

... do stuff that destroys the current selection then

saveSel.Select

And the problem with this is of course that the object to which saveSel
refers has been destroyed in the meantime. What I actually want is to
have
saveSel be a range (or ref to a range) of cells that is set to whatever
was
selected originally.

Any ideas?