Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Retain, restore selection?

I created an Excel VBA macro that processes a list of items in a column
As a visual aid, I modified the code to select the row of the ite
being processed.

But now when the macro is finished executing, the row following th
last column entry remains selected/hilighted.

How can I:
1) Save whatever cell(s) are selected upon entry to macro execution;
2) Restore the original selection when code is ready to exit?

Many thanks in advance...


Mekratri

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default Retain, restore selection?

Hi
try
sub foo()
dim rng as range
set rng = selection
'your code
rng.select
end sub

--
Regards
Frank Kabel
Frankfurt, Germany


I created an Excel VBA macro that processes a list of items in a
column. As a visual aid, I modified the code to select the row of the
item being processed.

But now when the macro is finished executing, the row following the
last column entry remains selected/hilighted.

How can I:
1) Save whatever cell(s) are selected upon entry to macro execution;
2) Restore the original selection when code is ready to exit?

Many thanks in advance...


Mekratrig


---
Message posted from http://www.ExcelForum.com/


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default Retain, restore selection?

And if you want to restore the active cell in a multicell selection:

Public Sub foo()
Dim rSelect As Range
Dim rActive As Range

Set rSelect = Selection
Set rActive = ActiveCell

'do your thing

rSelect.Select
rActive.Activate
End Sub


In article ,
"Frank Kabel" wrote:

Hi
try
sub foo()
dim rng as range
set rng = selection
'your code
rng.select
end sub

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default Retain, restore selection?

Hi JE
good point :-)
Frank

-----Original Message-----
And if you want to restore the active cell in a multicell

selection:

Public Sub foo()
Dim rSelect As Range
Dim rActive As Range

Set rSelect = Selection
Set rActive = ActiveCell

'do your thing

rSelect.Select
rActive.Activate
End Sub


In article ,
"Frank Kabel" wrote:

Hi
try
sub foo()
dim rng as range
set rng = selection
'your code
rng.select
end sub

.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Retain, restore selection?

That was exactly what I needed

--
Message posted from http://www.ExcelForum.com



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Limiting selection in a cell AND linking that selection to a list Lisa Excel Discussion (Misc queries) 1 July 28th 09 05:00 PM
De-dup and retain new records only jaltsman Excel Worksheet Functions 0 June 13th 08 03:11 AM
Copy Selection - Transpose Selection - Delete Selection Uninvisible Excel Discussion (Misc queries) 2 October 23rd 07 04:18 PM
retain cell formatting bob777 Excel Discussion (Misc queries) 1 November 2nd 05 05:02 PM
Excel VBA - Range(Selection, Selection.End(xlDown)).Name issue. jonH Excel Programming 3 June 7th 04 09:13 PM


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"