Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Simple question | New Users to Excel | |||
IF formula-simple question; simple operator | Excel Discussion (Misc queries) | |||
Simple Simple Excel usage question | Excel Discussion (Misc queries) | |||
simple question, hopefully a simple answer! | Excel Programming | |||
A simple question | Excel Programming |