ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Macro Question (https://www.excelbanter.com/excel-discussion-misc-queries/197241-macro-question.html)

ddbro

Macro Question
 
I have a macro written that drops down a line, copies it one to the left,
drops down 2 lines, moves back to the left and copies it back to the right of
the previous line. Macro works fine, except, I need to be able to start it
from different cells and regardless of where I put my cursor the macro always
runs from the cells it was in when I wrote it. How do I adjust it so it
starts from wherever the cursor is?
--
Dana

Bob Phillips[_3_]

Macro Question
 
Post the macro to give us something to work on.

--
__________________________________
HTH

Bob

"ddbro" wrote in message
...
I have a macro written that drops down a line, copies it one to the left,
drops down 2 lines, moves back to the left and copies it back to the right
of
the previous line. Macro works fine, except, I need to be able to start
it
from different cells and regardless of where I put my cursor the macro
always
runs from the cells it was in when I wrote it. How do I adjust it so it
starts from wherever the cursor is?
--
Dana




ddbro

Macro Question
 
Range("A26").Select
Selection.Cut
Range("B25").Select
ActiveSheet.Paste
Range("A27").Select
Selection.Cut
Range("C25").Select
ActiveSheet.Paste
Range("A28").Select
Selection.Cut
Range("D25").Select
ActiveSheet.Paste
End Sub


Simple little macro. What I want is the range to be wherever I place my
cursor.
--
Dana


"Bob Phillips" wrote:

Post the macro to give us something to work on.

--
__________________________________
HTH

Bob

"ddbro" wrote in message
...
I have a macro written that drops down a line, copies it one to the left,
drops down 2 lines, moves back to the left and copies it back to the right
of
the previous line. Macro works fine, except, I need to be able to start
it
from different cells and regardless of where I put my cursor the macro
always
runs from the cells it was in when I wrote it. How do I adjust it so it
starts from wherever the cursor is?
--
Dana





J Sedoff comRemove>

Macro Question
 
Here you go:

Sub moveCells()
'Range("A26").Select
ActiveCell.Cut
'Range("B25").Select
ActiveCell.Offset(-1, 1).Select
ActiveSheet.Paste

'Range("A27").Select
ActiveCell.Offset(2, -1).Cut
'Range("C25").Select
ActiveCell.Offset(0, 1).Select
ActiveSheet.Paste

'Range("A28").Select
ActiveCell.Offset(3, -2).Cut
'Range("D25").Select
ActiveCell.Offset(0, 1).Select
ActiveSheet.Paste

Application.CutCopyMode = False
End Sub

Hope this helps, Jim
--
I appreciate any feedback.

J Sedoff comRemove>

Macro Question
 
The first post was if you wanted to cut and paste the values, but if you just
want to copy them, you simply need to copy, paste-special transpose the cells!

In that case, here you go:

Sub CopyPasteSpecial()
Range(ActiveCell, ActiveCell.Offset(2, 0)).Copy
ActiveCell.Offset(-1, 1).PasteSpecial Paste:=xlPasteAll, _
Operation:=xlNone, SkipBlanks:=False, Transpose:=True
Application.CutCopyMode = False
End Sub

Hope this helps, Jim
--
I appreciate any feedback.


All times are GMT +1. The time now is 11:46 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com