![]() |
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 |
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/ |
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 |
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 . |
Retain, restore selection?
|
All times are GMT +1. The time now is 05:23 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com