+ Reply to Thread
Results 1 to 9 of 9

Copy a row and paste it a number of times based on a cell value

  1. #1
    Registered User
    Join Date
    05-01-2013
    Location
    shoreview mn
    MS-Off Ver
    Excel 2010
    Posts
    4

    Question Copy a row and paste it a number of times based on a cell value

    Not being a VBA expert, I hoping someone can help me. I've found several examples of things that are close but I haven't been able to modifiy anything to work.

    Here's what I have -

    In A4:T4 I have columns with calculations to perform and that I need to repeat on multiple rows based on the value in B2.

    In other words, If I have the value "5" in B2, then I want to copy A4:T4 and paste it 5 times, on the following rows A5:T5,A6:T6,A7:T7,A8:T8,A9:T9,A10:T10

    It would be nice if it would also clear the added rows when I change the number in B2 so if I went from 5 to 2, I wouldn't end up with clutter. I can have as many as 100 rows in this spreadsheet.

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

    Re: Copy a row and paste it a number of times based on a cell value

    Do you have a sample file that you can upload?

    To Attach a File:

    1. Click on Go Advanced
    2. In the frame Attach Files you will see the button Manage Attachments
    3. Click the button.
    4. A new window will open titled Manage Attachments - Excel Forum.
    5. Click the Browse... button to locate your file for uploading.
    6. This will open a new window File Upload.
    7. Once you have located the file to upload click the Open button. This window will close.
    8. You are now back in the Manage Attachments - Excel Forum window.
    9. Click the Upload button and wait until the file has uploaded.
    10. Close the window and then click Submit.
    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]

  3. #3
    Registered User
    Join Date
    05-01-2013
    Location
    shoreview mn
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Copy a row and paste it a number of times based on a cell value

    Here's what I've been doing manually that I'm trying to adjust to work as I described
    Attached Files Attached Files

  4. #4
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Copy a row and paste it a number of times based on a cell value

    Where do you want to copy the added rows? Is it on the same sheet, or new sheet? How many rows do you want to copy? Is it a single row, or all 17 rows?

  5. #5
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Copy a row and paste it a number of times based on a cell value

    Assuming you want to copy all rows. The result is in sheet2
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    05-01-2013
    Location
    shoreview mn
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Copy a row and paste it a number of times based on a cell value

    The result can be on any sheet but the result would like exactly like the sample. Enter the starting number and the number of codes. THe first detail line is replicated to match the number of codes, the column called "Numeric Value" is incremented by 1 until number of codes is met. the end goal is to calculate the check digit for each mumber in the sequence.

    Starting Number 07874205660
    Number of Codes 3

    Text Value Numeric Value 1 2 3 4 5 6 7 8 9 10 11 Odd digits Even digits Even + Odd Base Check Finisher Check Digit Full Number
    07874205661 07874205661 0 7 8 7 4 2 0 5 6 6 1 57 27 84 8.4 916 6 078742056616
    07874205662 07874205662 0 7 8 7 4 2 0 5 6 6 2 60 27 87 8.7 913 3 078742056623
    07874205663 07874205663 0 7 8 7 4 2 0 5 6 6 3 63 27 90 9 910 0 078742056630

  7. #7
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Copy a row and paste it a number of times based on a cell value

    Have you tried the attached?

  8. #8
    Registered User
    Join Date
    05-01-2013
    Location
    shoreview mn
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Copy a row and paste it a number of times based on a cell value

    I did, it gave me 3 duplicated rows on sheet 2 for every row on sheet 1

  9. #9
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Copy a row and paste it a number of times based on a cell value

    That is why I asked you which rows do you want to copy, is it row1 ,or2?

+ 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