+ Reply to Thread
Results 1 to 5 of 5

copy and paste macro using the active cell

  1. #1
    Registered User
    Join Date
    02-25-2007
    Location
    scotland
    Posts
    4

    copy and paste macro using the active cell

    i'm new to this computing stuff i wonder if someone can help,
    i have an excel sheet about 1000rows in use at present.
    i am trying to make a copy paste macro. to expain further- i want to copy c1 through to g1 and paste those cells to m1 throught to r1, then the next time i want to move down 7 rows and copy that range across .
    i recorded a macro to do this but when i move down to for example c8 and run the macro it copies and pastes the original c1-g1 ito m1-r1.
    i have had a go at reading the help but and trying a few things to no avail.
    it,s just normal numbers i want to copy and paste not formula or anything complicated.

  2. #2
    Forum Contributor
    Join Date
    08-19-2006
    Posts
    116
    Hi Norman

    I'm not sure it's what you want

    Range(Selection, Selection.End(xlToRight)).Select
    Selection.Copy
    ActiveCell.Offset(0, 10).Activate
    ActiveSheet.Paste

    First, you have to select the first cell of your range.

    For example,you have 1 in A1, 2 in B1, 3 in C1,4 in D1 and 1 in E1
    You select A1 and you execute this macro. You'll have 1 in K1...1 in O1. I don't understand one thing. If you copy C1 to G1, you'll paste from M1 to Q1 and not R1.You have written "i want to copy c1 through to g1 and paste those cells to m1 throught to r1.

  3. #3
    Registered User
    Join Date
    02-25-2007
    Location
    scotland
    Posts
    4

    copy and paste macro

    Raiby, thanks for taking the time to help me. i'll try to explain better.
    i want to copy six cells in a row, then paste them in the same row leaving one blank cell between the numbers i copy and the place i am copying to.
    then i need to move down 7 rows copy another six cells and paste them across that row as above, and so on. does that make sense to you?
    best regards
    norman jones

  4. #4
    Registered User
    Join Date
    02-25-2007
    Location
    scotland
    Posts
    4

    Smile thanks raiby

    raiby, i got it working great thank you very much
    norman jones

  5. #5
    Forum Contributor
    Join Date
    08-19-2006
    Posts
    116
    Hi Norman

    I'm sorry for the waiting period. I was busy. My macro works or did you found your solution?On my side i have found something

    If you have

    1 2 3 4 5
    ....
    7 8 9 10 11 12
    .....
    14 15 16 17 18
    ...
    21 22 23 24 25

    and if you want

    1in (A1) 2 in (B1) 3 in (C1) 4(D1) 5(E1) 1 in (G1) 2(H1) 3(I1) 4(J1) 5(K1)
    ....
    7(A7) 8(B7) 9(C7) 10(D7) 11(E7) 7(G7) 8(H7) 9(I7) 10(J7) 11(K7)
    .....
    14(A14) 15(B14) 16(C14) 17(D14) 18(E14) 14(G14) 15(H14) 16(I14) 17(J14) 18(K14)
    ...
    21(A21) 22(B21) 23(C21) 24(D21) 25(E21) 21(G21) 22(H21) 23(I21) 24(J21) 25(K21)

    use this macro (In fact, if you want to paste only the rows (1,7,14,21)

    For i = 1 To 20 Step 7
    '1 If your range begins in the first row
    For j = 1 To 4
    '4 if hou have 5 columns (1,2,3,4,5)
    Cells(i + 6, j).Select
    ActiveCell.Offset(0, 0).Select
    Range(Selection, Selection.End(xlToRight)).Select
    Selection.Copy
    ActiveCell.Offset(0, 6).Activate
    ActiveSheet.Paste
    Next j
    Next i

    You have to select the cell A1 first.You'll have one column between E1 and G1. Is that you want?
    Last edited by Raiby; 03-02-2007 at 05:02 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1