Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default (Probably) simple question

Hi,

I have a macro, but when it runs I want the cell that is selected
immediately afterwards to be the cell that was selected immediately before
the macro ran.

I am sure that this is quite an easy thing to do in VB, but I don't know how
to do it.

Any help is much appreciated,

Jon.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default (Probably) simple question

Hi
try something like

sub foo()
Dim rng as range
set rng = Activecell
'...
'...your macro code
'...
rng.select
end sub

if you also change the worksheet and/or workbook you have to store them
in a similar way


--
Regards
Frank Kabel
Frankfurt, Germany

Jonathan Vickers wrote:
Hi,

I have a macro, but when it runs I want the cell that is selected
immediately afterwards to be the cell that was selected immediately
before the macro ran.

I am sure that this is quite an easy thing to do in VB, but I don't
know how to do it.

Any help is much appreciated,

Jon.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 599
Default (Probably) simple question

Jon

In addition to Franks response, you can redesign your macro so that the
selection doesn't change when it runs. It is generally not necessary to
select objects in order to work with them. Whenever you have a construct
like this

Range("A1").Select
Selection.Interior.ColorIndex = 1

you can change it to simply

Range("A1").Interior.ColorIndex = 1

By not selecting objects in order to change their properties or invoke their
methods, you can greatly increase the speed at which your macro runs. It
also looks cooler.

If your code isn't too lengthy, you can post it here and I will show you how
to get around selecting.

--
Dick Kusleika
MVP - Excel
www.dicks-clicks.com
Post all replies to the newsgroup.

"Jonathan Vickers" wrote in message
...
Hi,

I have a macro, but when it runs I want the cell that is selected
immediately afterwards to be the cell that was selected immediately before
the macro ran.

I am sure that this is quite an easy thing to do in VB, but I don't know

how
to do it.

Any help is much appreciated,

Jon.




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
Simple question [email protected] New Users to Excel 4 March 24th 08 07:47 PM
IF formula-simple question; simple operator Rich D Excel Discussion (Misc queries) 4 December 6th 07 03:36 PM
Simple Simple Excel usage question BookerW Excel Discussion (Misc queries) 1 June 23rd 05 10:06 PM
simple question, hopefully a simple answer! Matt B Excel Programming 5 January 13th 04 08:43 PM
A simple question Kirk[_2_] Excel Programming 0 July 25th 03 04:38 PM


All times are GMT +1. The time now is 10:09 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"