Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
sony654
 
Posts: n/a
Default Macro - Return to starting cell

I am writing a macro that will always start in a different cell, but needs to
reference back to the starting cell each time it is run. For example, if the
cursor is in cell d3 when the macro is run, the macro must return to d3 when
finished. The next time the macro is run, it will start in e3, and return to
e3 when finished. I use the macro recorder to write my macros, how do I
write it to have the routine always end in the starting cell?


--
Sony Luvy
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
JE McGimpsey
 
Posts: n/a
Default Macro - Return to starting cell

One way:

Dim rReturn As Range
Set rReturn = ActiveCell

'do your routine here

rReturn.Activate



In article ,
"sony654" wrote:

I am writing a macro that will always start in a different cell, but needs to
reference back to the starting cell each time it is run. For example, if the
cursor is in cell d3 when the macro is run, the macro must return to d3 when
finished. The next time the macro is run, it will start in e3, and return to
e3 when finished. I use the macro recorder to write my macros, how do I
write it to have the routine always end in the starting cell?

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
sony654
 
Posts: n/a
Default Macro - Return to starting cell

OK I'm lost: How is this written

1) The cursor is in d3.
2) goto a3, copy a3:a7
3) *** how do i automate the return to d3? ***
4) paste to d3:d7

--
Sony Luvy


"JE McGimpsey" wrote:

One way:

Dim rReturn As Range
Set rReturn = ActiveCell

'do your routine here

rReturn.Activate



In article ,
"sony654" wrote:

I am writing a macro that will always start in a different cell, but needs to
reference back to the starting cell each time it is run. For example, if the
cursor is in cell d3 when the macro is run, the macro must return to d3 when
finished. The next time the macro is run, it will start in e3, and return to
e3 when finished. I use the macro recorder to write my macros, how do I
write it to have the routine always end in the starting cell?


  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
JE McGimpsey
 
Posts: n/a
Default Macro - Return to starting cell

To do it the way you say:

Dim rReturn As Range
Set rReturn = ActiveCell
Range("A3:A7").Select
Selection.Copy
rReturn.Activate
ActiveSheet.Paste

OTOH, you could replace the whole thing with

Range("A3:A7").Copy Destination:=ActiveCell


In article ,
"sony654" wrote:

OK I'm lost: How is this written

1) The cursor is in d3.
2) goto a3, copy a3:a7
3) *** how do i automate the return to d3? ***
4) paste to d3:d7

  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
sony654
 
Posts: n/a
Default Macro - Return to starting cell

JE - Thanks for quick responses. How do I record the macro? Using macro
recorder is pretty limiting. It is easier said than done. Thanks - Sony


--
Sony Luvy


"JE McGimpsey" wrote:

To do it the way you say:

Dim rReturn As Range
Set rReturn = ActiveCell
Range("A3:A7").Select
Selection.Copy
rReturn.Activate
ActiveSheet.Paste

OTOH, you could replace the whole thing with

Range("A3:A7").Copy Destination:=ActiveCell


In article ,
"sony654" wrote:

OK I'm lost: How is this written

1) The cursor is in d3.
2) goto a3, copy a3:a7
3) *** how do i automate the return to d3? ***
4) paste to d3:d7




  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
R..VENKATARAMAN
 
Posts: n/a
Default Macro - Return to starting cell

try something like this
(at ther beginning of the macro after public sub -----())

dim cc as range
set cc=activecell
then other code staements

(at the end of the macro before end sub
type

cc.select

try this and see whether you get what you want.

"sony654" wrote in message
...
I am writing a macro that will always start in a different cell, but needs
to
reference back to the starting cell each time it is run. For example, if
the
cursor is in cell d3 when the macro is run, the macro must return to d3
when
finished. The next time the macro is run, it will start in e3, and return
to
e3 when finished. I use the macro recorder to write my macros, how do I
write it to have the routine always end in the starting cell?


--
Sony Luvy



  #7   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Bob Phillips
 
Posts: n/a
Default Macro - Return to starting cell

You don't.

Go into the VBIDE, Alt-F11, Insert a new code module, InsertModule, and
add the macro

Sub CopyData()
Range("A3:A7").Copy Destination:=ActiveCell
End Sub

and run that from excel.

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"sony654" wrote in message
...
JE - Thanks for quick responses. How do I record the macro? Using macro
recorder is pretty limiting. It is easier said than done. Thanks - Sony


--
Sony Luvy


"JE McGimpsey" wrote:

To do it the way you say:

Dim rReturn As Range
Set rReturn = ActiveCell
Range("A3:A7").Select
Selection.Copy
rReturn.Activate
ActiveSheet.Paste

OTOH, you could replace the whole thing with

Range("A3:A7").Copy Destination:=ActiveCell


In article ,
"sony654" wrote:

OK I'm lost: How is this written

1) The cursor is in d3.
2) goto a3, copy a3:a7
3) *** how do i automate the return to d3? ***
4) paste to d3:d7




  #8   Report Post  
Posted to microsoft.public.excel.worksheet.functions
JE McGimpsey
 
Posts: n/a
Default Macro - Return to starting cell

Take a look at David McRitchie's "Getting Started with Macros":

http://www.mvps.org/dmcritchie/excel/getstarted.htm

In article ,
"sony654" wrote:

JE - Thanks for quick responses. How do I record the macro? Using macro
recorder is pretty limiting. It is easier said than done. Thanks - Sony

  #9   Report Post  
Posted to microsoft.public.excel.worksheet.functions
sony654
 
Posts: n/a
Default Macro - Return to starting cell

JE - I got it. Thankyou very much for the insight on this one. I have some
final mods to make and good to go. Thanks again - Sony
--
Sony Luvy


"JE McGimpsey" wrote:

Take a look at David McRitchie's "Getting Started with Macros":

http://www.mvps.org/dmcritchie/excel/getstarted.htm

In article ,
"sony654" wrote:

JE - Thanks for quick responses. How do I record the macro? Using macro
recorder is pretty limiting. It is easier said than done. Thanks - Sony


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
Returning Macro to Starting Cell sony654 Excel Worksheet Functions 3 February 25th 06 12:02 PM
Urgent date/scheduling calc needed jct Excel Worksheet Functions 3 February 24th 06 01:36 AM
Macro help - copy a cell down gjcase Excel Discussion (Misc queries) 3 September 4th 05 05:09 AM
copying cell names Al Excel Discussion (Misc queries) 12 August 11th 05 03:01 PM
Syntax for inferred cell references donesquire Excel Worksheet Functions 4 April 4th 05 09:29 PM


All times are GMT +1. The time now is 03:56 PM.

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"