Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 238
Default Unselect or deselect cells

After a macro runs, sometimes a block of cells remains selected. Is
there a command I can put at the end of the macro to clear the
selection?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Unselect or deselect cells

Set r = Selection
' your code here
r.Select
--
Gary''s Student - gsnu2007L


"Fan924" wrote:

After a macro runs, sometimes a block of cells remains selected. Is
there a command I can put at the end of the macro to clear the
selection?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Unselect or deselect cells

Perhaps this previous posting of mine (a response to another person using
Select/Selection type constructions) will be of some help to you in your
programming efforts...

Whenever you see code constructed like this...

Range("A1").Select
Selection.<whatever

you can almost always do this instead...

Range("A1").<whatever

In your particular case, you have this...

Range("C2:C8193").Select 'select cells to export
For Each r In Selection.Rows

which, using the above concept, can be reduced to this...

For Each r In Range("C2:C8193").Rows

Notice, all I have done is replace Selection with the range you Select(ed)
in the previous statement and eliminate the process of doing any
Select(ion)s. Stated another way, the Selection produced from
Range(...).Select is a range and, of course, Range(...) is a range... and,
in fact, they are the same range, so it doesn't matter which one you use.
The added benefit of not selecting ranges first is your active cell does not
change.

--
Rick (MVP - Excel)


"Fan924" wrote in message
...
After a macro runs, sometimes a block of cells remains selected. Is
there a command I can put at the end of the macro to clear the
selection?


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 238
Default Unselect or deselect cells

On Feb 23, 2:50 am, Gary''s Student
wrote:
Set r = Selection
' your code here
r.Select
--
Gary''s Student - gsnu2007L

"Fan924" wrote:
After a macro runs, sometimes a block of cells remains selected. Is
there a command I can put at the end of the macro to clear the
selection?


This did not work for me. Maybe it is my version, excel 97
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
Deselect (Unselect) Cells gtabmx Excel Discussion (Misc queries) 15 January 6th 10 02:13 PM
unselect cells tgi Excel Discussion (Misc queries) 1 October 1st 09 03:21 AM
unselect cells tgi Excel Discussion (Misc queries) 2 October 1st 09 01:39 AM
Unselect? Deselect? jayklmno Excel Programming 1 February 21st 07 10:30 PM
Unselect Cells bobwilson[_12_] Excel Programming 6 April 4th 06 12:02 AM


All times are GMT +1. The time now is 04:34 AM.

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

About Us

"It's about Microsoft Excel"