Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel: moving data around columns

Status
Not open for further replies.

pendle666

Technical User
Jan 30, 2003
295
GB
Hello

I have a lot of data in a spreadsheet refering to individuals:

first name, surname, area, job title, contract start date 1, contract end date 2, etc etc

What I wish to do is copy/paste from the line that I'm on to other cells in that line.

I have recorded a macro, detailed below. However it refers to the line that I'm on when I recorded the macro and I want it to be on the active line - in the recording it was line 64, but it might be 364 that I'm working in. Could some kind person point me in the right direction?

Range("AG64:AL64").Select
Selection.Copy
Range("AM64").Select
ActiveSheet.Paste
Range("L64:Q64").Select
Application.CutCopyMode = False
Selection.Copy
Range("AG64").Select
ActiveSheet.Paste
Range("L64").Select
Application.CutCopyMode = False


regards

Pendle
 
hi,
Code:
Sub CopyShiftThisRow()
    With ActiveCell
    'copy range 1
        Range(Cells(.Row, "AG"), Cells(.Row, "AL")).Copy
        Range("AM64").PasteSpecial xlPasteAll
    'copy range 2
        Range(Cells(.Row, "L"), Cells(.Row, "Q")).Copy
        Range("AG64").PasteSpecial xlPasteAll
    'RIP
        Cells(.Row, "L"), Select
        Application.CutCopyMode = False
    End With
End Sub

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
oops, I missed some stuff
Code:
    With ActiveCell
    'copy range 1
        Range(Cells(.Row, "AG"), Cells(.Row, "AL")).Copy
        Cells(.Row, "AM").PasteSpecial xlPasteAll
    'copy range 2
        Range(Cells(.Row, "L"), Cells(.Row, "Q")).Copy
        Cells(.Row, "AG").PasteSpecial xlPasteAll
    'RIP
        Cells(.Row, "L").Select
        Application.CutCopyMode = False
    End With

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
That's brilliant.

Thank you very much for your help.


Pendle
 
Skip,

Could you use the Destination argument of Copy rather then the extra line for paste?

Code:
With ActiveCell
    'copy range 1
        Range(Cells(.Row, "AG"), Cells(.Row, "AL")).Copy (Cells(.Row, "AM"))
    'copy range 2
        Range(Cells(.Row, "L"), Cells(.Row, "Q")).Copy (Cells(.Row, "AG"))
    'RIP
        Cells(.Row, "L").Select
        Application.CutCopyMode = False
    End With

Never knock on Death's door: ring the bell and run away! Death really hates that!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top