Consulting

Results 1 to 5 of 5

Thread: Solved: help with copy and paste

  1. #1

    Solved: help with copy and paste

    Hello,

    A simple task for you, hard for me:

    I want to go to a cell (say I6)
    Highlight cells I6:W6
    Copy these cells
    Scroll down 25 rows to cell I31
    Highlight cells I31:W31
    Paste

    Now Highlight cells I31:W31
    Copy these cells
    Scroll down 25 rows to cell I56
    Highlight cells I56:W56
    Paste

    Repeat 50 times, each time copying the last range of cells you pasted to a range 25 rows beneath it
    I've only done it twice in the example above, just to give an example of what I want to do, but I have a 15000 row worksheet and I need a macro.

    I've tried "record new macro" but it keeps running the macro and then going back to my original starting point (Cell I6) instead of the last cell I pasted to.

    Hope you can understand this

    peter_act

  2. #2
    Mac Moderator VBAX Guru mikerickson's Avatar
    Joined
    May 2007
    Location
    Davis CA
    Posts
    2,778
    The process you describes makes 50 copies of I6:W6, as does this[VBA]Dim i As Long
    With Range("I6:W6")
    For i = 1 to 50
    .Offset(25*i,0).Value = .Value
    Next i
    End With[/VBA]

  3. #3

    Excell copy/paste

    Thanks for that,

    It almost worked - unfortunately it pastes as "paste special" ->values
    instead of copying the formulas from I6:W6 (my fault - I wasn't clear on that in my explanantion)

    I'm assuming the code "Value = .Value " is doing this.
    Can you advise?

    Still, what you gave me was great - I would never have got there

    Thanks,

    peter_act

  4. #4
    Mac Moderator VBAX Guru mikerickson's Avatar
    Joined
    May 2007
    Location
    Davis CA
    Posts
    2,778
    [VBA]Dim i As Long
    With Range("I6:W6")
    For i = 1 To 50
    .Copy Destination:=.Offset(25*i,0)
    Next i
    End With
    Application.CutCopyMode = False [/VBA]

  5. #5
    Many thanks for that, worked perfectly.

    As I said I wouldn't have got there by myself
    I've now added it to my little bits of Excel macro code for future reference

    Thanks again

    peter_act

Posting Permissions

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