Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
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
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
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
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
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
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
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
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
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
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
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
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Macro for cell selection starting with Last Cell | Excel Worksheet Functions | |||
Macro help - copy a cell down | Excel Discussion (Misc queries) | |||
Relative Cell position NOT working with or without macro | Excel Discussion (Misc queries) | |||
Perform oiperations relative to initial selected cell | Excel Discussion (Misc queries) | |||
GET.CELL | Excel Worksheet Functions |