View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
DrFear DrFear is offline
external usenet poster
 
Posts: 4
Default retain Selection

Should work perhaps ... but doesn't. I wasn't clear enough: after changing
the selection, I actuallyu delete the columns containing the cells originally
selected before repopulating. So in my code saveCell does not even point to
Nothing, it just errors to object not existing.

I do navigate to another workbook during ... steps, but at the time of my
unsuccessful saveSel.Select, ActiveWorkbook and ActiveSheet have been
restored to where the original selection was.

It still seems to me the problem is Set does not create a range object but
creates a pointer to a range object, and that object gets destroyed.

If I could get the range of Application.Selection expressed as a text string
I could later restore it with Range(storedString).Select - but how would I
get that text string in the first place, and is this not a rather clumsy way
of doing things?

Thanks for any further suggestions!

"Gary''s Student" wrote:

It should work exactly as you have coded it. If, however, you are navigating
between workbook/worksheets then save that information as well.
--
Gary''s Student - gsnu200785


"DrFear" wrote:

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?