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
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
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" <sony654@discussions.microsoft.com> wrote in message
news:6CCB4D27-6368-4D1B-B254-854CB70642EF@microsoft.com...
> 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
>
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" <sony654@discussions.microsoft.com> wrote in message
> news:6CCB4D27-6368-4D1B-B254-854CB70642EF@microsoft.com...
> > 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
> >
>
>
>
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"
<sony654@discussions.microsoft.com> 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
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" <sony654@discussions.microsoft.com> wrote in message
news:57CA0FB5-C45B-4E2E-9247-E5091FE276D0@microsoft.com...
> 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" <sony654@discussions.microsoft.com> wrote in message
> > news:6CCB4D27-6368-4D1B-B254-854CB70642EF@microsoft.com...
> > > 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
> > >
> >
> >
> >
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" <sony654@discussions.microsoft.com> wrote in message
> news:57CA0FB5-C45B-4E2E-9247-E5091FE276D0@microsoft.com...
> > 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" <sony654@discussions.microsoft.com> wrote in message
> > > news:6CCB4D27-6368-4D1B-B254-854CB70642EF@microsoft.com...
> > > > 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
> > > >
> > >
> > >
> > >
>
>
>
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"
> <sony654@discussions.microsoft.com> 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
>
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks