Consulting

Results 1 to 5 of 5

Thread: insert rows and paste in section from a range

  1. #1
    VBAX Regular
    Joined
    Dec 2015
    Posts
    57
    Location

    insert rows and paste in section from a range

    I am trying to create a macro that will insert a range starting where the active cell is located. For example a user needs to add a section where they are, they would click on the cell where they want to start and then press a macro button and a range would be inserted. I believed breaking it into two parts would make sense like inserting blank row and then copy pasting the range needed in the section but possibly insert cells can do it directly.

    So if I need to insert cells into C10 to E15 from Q100 to S115 (the range I want to copy) what would code be? I need it dynamic meaning the user may be in another area so that the only thing fixed is Q100 to S115 (the range being copied). I don't want the range moved just copied in.

  2. #2
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,876
    Supply a workbook to play with.
    Q100:S115 is 16 rows, C10:E15 is 6 rows.
    Do you want cells inserted (so that cells below are moved down) or just written over?
    Also note that if entire sheet rows are inserted above row 100, Q100:S115 will be moved down to another address.
    Attached Files Attached Files
    Last edited by p45cal; 10-15-2017 at 10:11 AM.
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

  3. #3
    VBAX Regular
    Joined
    Dec 2015
    Posts
    57
    Location
    thank you for sample file. file does copy paste section but it overwrites. I was looking for paste with inserting rows so rows move below. I would need move the copy from section above the row paste area so it doesn't move. see example of what I am trying to do.
    Attached Files Attached Files

  4. #4
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,876
    Quote Originally Posted by SteveM99 View Post
    tI was looking for paste with inserting rows so rows move below.
    But you haven't said whether you want entire rows (the width of the entire sheet) inserted or just a block of 6x4 cells inserted. The attached contains both options.
    Attached Files Attached Files
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

  5. #5
    VBAX Regular
    Joined
    Dec 2015
    Posts
    57
    Location
    Thank you very much for the codes. Spot on!

Posting Permissions

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