+ Reply to Thread
Results 1 to 12 of 12

Copy and insert rows with contents and format based on specific number

  1. #1
    Forum Contributor
    Join Date
    02-07-2011
    Location
    Bhutan
    MS-Off Ver
    Excel 2007
    Posts
    244

    Copy and insert rows with contents and format based on specific number

    Hi ,
    I have this excel sheet. What I was wondering is how to copy and insert the contents of the row in the same sheet when i click the button.
    For example, if Column D ie.Repetation is 4, then the contents from e10 to s10 will get copies 4 times below e10
    then if on d18 if the repetation is 6, then the the contents from e18 to s18 will get copies 6 times below e18
    then if on d32 if the repetation is 3, then the the contents from e32 to s32 will get copies 6 times below e32

    All I want is to have a common code so that I can copy and use the same in different sheets where there are more test subjects.ie.Column D is having more than 10-15 test.

    I am uploading the excel file for your reference.
    Thanks in advance,
    Attached Files Attached Files
    Last edited by fatalcore; 01-13-2012 at 03:39 AM. Reason: Updated a new file with before after as suggested.

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Copy and insert rows with contents and format based on specific number

    Your sample workbook should have BEFORE/AFTER sheets so we can see clearly what you have in mind.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Forum Contributor
    Join Date
    02-07-2011
    Location
    Bhutan
    MS-Off Ver
    Excel 2007
    Posts
    244

    Re: Copy and insert rows with contents and format based on specific number

    Hi JBeaucaire , I have updated the file as suggested.

  4. #4
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Copy and insert rows with contents and format based on specific number

    Should your data be copied along with the merging?
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  5. #5
    Forum Contributor
    Join Date
    02-07-2011
    Location
    Bhutan
    MS-Off Ver
    Excel 2007
    Posts
    244

    Re: Copy and insert rows with contents and format based on specific number

    Yes, I want that with merge. As the test details are quite large and originaly in parapragh. So I have merged the lines.
    Thanks in advance.

  6. #6
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Copy and insert rows with contents and format based on specific number

    This should do it:

    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    02-07-2011
    Location
    Bhutan
    MS-Off Ver
    Excel 2007
    Posts
    244

    Re: Copy and insert rows with contents and format based on specific number

    This is great, Only one problem, if by mistake if I click it twice or update the number in column D after the code has run once then the lines are generated in a puculiar way like more lines are getting generated then required lines. Can this be solved anyhow. Thanks in advance.

  8. #8
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Copy and insert rows with contents and format based on specific number

    Remove the button. Run the macro from the Alt-F8 popup list. Now you can't double run the macro that easily. (chuckle)


    If that takes care of your original need, please click EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.

  9. #9
    Forum Contributor
    Join Date
    02-07-2011
    Location
    Bhutan
    MS-Off Ver
    Excel 2007
    Posts
    244

    Re: Copy and insert rows with contents and format based on specific number

    Right ... thanks.
    Last edited by fatalcore; 01-12-2012 at 12:43 AM.

  10. #10
    Forum Contributor
    Join Date
    02-07-2011
    Location
    Bhutan
    MS-Off Ver
    Excel 2007
    Posts
    244

    Re: Copy and insert rows with contents and format based on specific number

    Just a small change. Can the above code be modified a little bit. So that if the column D contains "0" then the row will be deleted and continue. Please.

  11. #11
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Copy and insert rows with contents and format based on specific number

    No, but it can be rewritten completely.
    Please Login or Register  to view this content.

  12. #12
    Forum Contributor
    Join Date
    02-07-2011
    Location
    Bhutan
    MS-Off Ver
    Excel 2007
    Posts
    244

    Re: Copy and insert rows with contents and format based on specific number

    Thanks a ton. God send !

+ 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