Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
sony654
 
Posts: n/a
Default returning macro value to starting cell (different each time)

In my worksheet I am going to launch a macro from a different cell address
each time it is run. I want the macro execution to always complete in the
starting cell
(return to it). Any ideas please?

Sony

  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Paul B
 
Posts: n/a
Default returning macro value to starting cell (different each time)

Sony, you can do most things in VBA without selecting the cells, may want to
post your code and see if that is the case, that said, give this a try

Set Oldsheet = ActiveSheet
oldcell = Selection.Address

'put your code here

Oldsheet.Select
Range(oldcell).Select


--
Paul B
Always backup your data before trying something new
Please post any response to the newsgroups so others can benefit from it
Feedback on answers is always appreciated!
Using Excel 2002 & 2003

"sony654" wrote in message
...
In my worksheet I am going to launch a macro from a different cell address
each time it is run. I want the macro execution to always complete in the
starting cell
(return to it). Any ideas please?

Sony



  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
sony654
 
Posts: n/a
Default returning macro value to starting cell (different each time)

Paul - Here is how it is supposed to work: How do I fit your code in to mine
below (this is my current code (below)) Thanks for reviewing

A B C D E F G H
1
2 10 10 11
3 12 12 8
4 8 8 7
5 9 9 7
6
7 39 39 33
8
9

Cell e2 will be active before the macro is run the first time. The macro
will (f5) go to and select range b2:b7, and copy back to d2:d7. The second
time run, cell e2 will be active, and should copy b2:b7 back to e2:e7. I
always want the b2:b7 selection to be copied back to the starting cell.

Sub Macro4()
'
' Macro4 Macro
' Macro recorded 2/4/2006 by slpic
'
' Keyboard Shortcut: Ctrl+w
'
Range("F6").Select
Application.Goto Reference:="R2C2"
Range("b2:b7").Select
Selection.Copy
Range("d2").Select
ActiveSheet.Paste
Application.CutCopyMode = False
Range("F7").Select
End Sub


--
Sony Luvy


"Paul B" wrote:

Sony, you can do most things in VBA without selecting the cells, may want to
post your code and see if that is the case, that said, give this a try

Set Oldsheet = ActiveSheet
oldcell = Selection.Address

'put your code here

Oldsheet.Select
Range(oldcell).Select


--
Paul B
Always backup your data before trying something new
Please post any response to the newsgroups so others can benefit from it
Feedback on answers is always appreciated!
Using Excel 2002 & 2003

"sony654" wrote in message
...
In my worksheet I am going to launch a macro from a different cell address
each time it is run. I want the macro execution to always complete in the
starting cell
(return to it). Any ideas please?

Sony




  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Fred Holmes
 
Posts: n/a
Default returning macro value to starting cell (different each time)

Sub Macro_X()
Dim r As String
r = ActiveCell.Address
MsgBox r
Range("A1").Select
MsgBox "Cell A1 has been selected"
Range(r).Activate
End Sub


On Sat, 4 Feb 2006 18:11:26 -0800, "sony654"
wrote:

In my worksheet I am going to launch a macro from a different cell address
each time it is run. I want the macro execution to always complete in the
starting cell
(return to it). Any ideas please?

Sony

  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Paul B
 
Posts: n/a
Default returning macro value to starting cell (different each time)

sony654, I am not clear on what you want to do, at first thought you only
wanted to go back to the cell you were in when you started the macro, now "I
always want the b2:b7 selection to be copied back to the starting cell" in
your example e2 is the starting cell each time but you are putting the data
in d and then e?? maybe something like this will put what's in B2:B7 where
the activecell is at, will that work? Range("B2:B7").Copy
Destination:=ActiveCell



--
Paul B
Always backup your data before trying something new
Please post any response to the newsgroups so others can benefit from it
Feedback on answers is always appreciated!
Using Excel 2002 & 2003

"sony654" wrote in message
...
Paul - Here is how it is supposed to work: How do I fit your code in to

mine
below (this is my current code (below)) Thanks for reviewing

A B C D E F G H
1
2 10 10 11
3 12 12 8
4 8 8 7
5 9 9 7
6
7 39 39 33
8
9

Cell e2 will be active before the macro is run the first time. The macro
will (f5) go to and select range b2:b7, and copy back to d2:d7. The

second
time run, cell e2 will be active, and should copy b2:b7 back to e2:e7. I
always want the b2:b7 selection to be copied back to the starting cell.

Sub Macro4()
'
' Macro4 Macro
' Macro recorded 2/4/2006 by slpic
'
' Keyboard Shortcut: Ctrl+w
'
Range("F6").Select
Application.Goto Reference:="R2C2"
Range("b2:b7").Select
Selection.Copy
Range("d2").Select
ActiveSheet.Paste
Application.CutCopyMode = False
Range("F7").Select
End Sub


--
Sony Luvy


"Paul B" wrote:

Sony, you can do most things in VBA without selecting the cells, may

want to
post your code and see if that is the case, that said, give this a try

Set Oldsheet = ActiveSheet
oldcell = Selection.Address

'put your code here

Oldsheet.Select
Range(oldcell).Select


--
Paul B
Always backup your data before trying something new
Please post any response to the newsgroups so others can benefit from it
Feedback on answers is always appreciated!
Using Excel 2002 & 2003

"sony654" wrote in message
...
In my worksheet I am going to launch a macro from a different cell

address
each time it is run. I want the macro execution to always complete in

the
starting cell
(return to it). Any ideas please?

Sony








  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
sony654
 
Posts: n/a
Default returning macro value to starting cell (different each time)

Paul, Sorry. D2 is the active cell the first time the macro is run. Then E2
the second time the macro is run. The F2 the third time the macro is run,
and so on. B2:B5 is always copied back to the active cell position.
Hopefully that clarifies what I'm trying to accomplish. Thanks Sony
--
Sony Luvy


"Paul B" wrote:

sony654, I am not clear on what you want to do, at first thought you only
wanted to go back to the cell you were in when you started the macro, now "I
always want the b2:b7 selection to be copied back to the starting cell" in
your example e2 is the starting cell each time but you are putting the data
in d and then e?? maybe something like this will put what's in B2:B7 where
the activecell is at, will that work? Range("B2:B7").Copy
Destination:=ActiveCell



--
Paul B
Always backup your data before trying something new
Please post any response to the newsgroups so others can benefit from it
Feedback on answers is always appreciated!
Using Excel 2002 & 2003

"sony654" wrote in message
...
Paul - Here is how it is supposed to work: How do I fit your code in to

mine
below (this is my current code (below)) Thanks for reviewing

A B C D E F G H
1
2 10 10 11
3 12 12 8
4 8 8 7
5 9 9 7
6
7 39 39 33
8
9

Cell e2 will be active before the macro is run the first time. The macro
will (f5) go to and select range b2:b7, and copy back to d2:d7. The

second
time run, cell e2 will be active, and should copy b2:b7 back to e2:e7. I
always want the b2:b7 selection to be copied back to the starting cell.

Sub Macro4()
'
' Macro4 Macro
' Macro recorded 2/4/2006 by slpic
'
' Keyboard Shortcut: Ctrl+w
'
Range("F6").Select
Application.Goto Reference:="R2C2"
Range("b2:b7").Select
Selection.Copy
Range("d2").Select
ActiveSheet.Paste
Application.CutCopyMode = False
Range("F7").Select
End Sub


--
Sony Luvy


"Paul B" wrote:

Sony, you can do most things in VBA without selecting the cells, may

want to
post your code and see if that is the case, that said, give this a try

Set Oldsheet = ActiveSheet
oldcell = Selection.Address

'put your code here

Oldsheet.Select
Range(oldcell).Select


--
Paul B
Always backup your data before trying something new
Please post any response to the newsgroups so others can benefit from it
Feedback on answers is always appreciated!
Using Excel 2002 & 2003

"sony654" wrote in message
...
In my worksheet I am going to launch a macro from a different cell

address
each time it is run. I want the macro execution to always complete in

the
starting cell
(return to it). Any ideas please?

Sony







  #7   Report Post  
Posted to microsoft.public.excel.worksheet.functions
sony654
 
Posts: n/a
Default returning macro value to starting cell (different each time)

Fred, Is ActiveCell.Address literal, or a "cell" address. I don;t mean to
look so elementary on this. But I appreciate your solution, it will be great
- Sony
--
Sony Luvy


"Fred Holmes" wrote:

Sub Macro_X()
Dim r As String
r = ActiveCell.Address
MsgBox r
Range("A1").Select
MsgBox "Cell A1 has been selected"
Range(r).Activate
End Sub


On Sat, 4 Feb 2006 18:11:26 -0800, "sony654"
wrote:

In my worksheet I am going to launch a macro from a different cell address
each time it is run. I want the macro execution to always complete in the
starting cell
(return to it). Any ideas please?

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
Macro for cell selection starting with Last Cell Valerie Excel Worksheet Functions 4 December 9th 05 08:25 PM
Macro help - copy a cell down gjcase Excel Discussion (Misc queries) 3 September 4th 05 05:09 AM
Relative Cell position NOT working with or without macro Scratching my Head Excel Discussion (Misc queries) 6 May 30th 05 06:12 PM
Perform oiperations relative to initial selected cell scratching my head Excel Discussion (Misc queries) 1 May 30th 05 05:42 PM
GET.CELL Biff Excel Worksheet Functions 2 November 24th 04 07:16 PM


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

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"