Macro Question

D

ddbro

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?
 
D

ddbro

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.
 
J

J Sedoff comRemove>

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
 
J

J Sedoff comRemove>

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top