+ Reply to Thread
Results 1 to 8 of 8

Macro that copies a row n number of times that is specified in a certain cell

  1. #1
    Registered User
    Join Date
    05-18-2015
    Location
    America
    MS-Off Ver
    MS Office 2010
    Posts
    23

    Macro that copies a row n number of times that is specified in a certain cell

    dates -- duration -- volts
    11/22/13 -- 22 -- 55.4
    5/6/15 -- 8 -- 22.3
    12/23/14 -- 13 -- 13

    I want to figure out how to duplicate each row of data the number of times that it listed under duration. So, I would want the row of 11/22/13 to be copied 22 times and the row of 5/6/15 to be copied 8 times... But i would need this for hundreds of lines of data.

    Is this possible with a formula or macro? Any help or assistance would be greatly appreciated!

  2. #2
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Macro that copies a row n number of times that is specified in a certain cell

    Attach a sample workbook. Make sure there is just enough data to make it clear what is needed. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are demonstrated, mock them up manually if needed. Remember to desensitize the data.

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    View Pic


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  3. #3
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Macro that copies a row n number of times that is specified in a certain cell

    Maybe:

    Please Login or Register  to view this content.
    Assumes your Columns are A B and C.

  4. #4
    Registered User
    Join Date
    05-18-2015
    Location
    America
    MS-Off Ver
    MS Office 2010
    Posts
    23

    Re: Macro that copies a row n number of times that is specified in a certain cell

    Unfortunately, the data is confidential, which is why I can't upload a sample. I just thought there was a way that I could do it on my own

  5. #5
    Registered User
    Join Date
    05-18-2015
    Location
    America
    MS-Off Ver
    MS Office 2010
    Posts
    23

    Re: Macro that copies a row n number of times that is specified in a certain cell

    OMG! This worked! I can't believe it thank you!! I am looking at the rows now and there is one extra row for each entry now. Is there anyway to tweak this? So for example row 11/22/13 has 23 instead of 22 copies. Here is your macro again:

    Sub Faintkitara()
    Dim i As Long
    With Application
    .ScreenUpdating = False
    .Calculation = xlCalculationManual
    End With
    For i = Range("A" & Rows.Count).End(3).Row To 2 Step -1
    Rows(i).Copy
    Rows(i).Resize(Range("D" & i).Value).Insert
    Next i
    With Application
    .ScreenUpdating = True
    .Calculation = xlCalculationAutomatic
    End With
    End Sub

  6. #6
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Macro that copies a row n number of times that is specified in a certain cell

    You're welcome. Glad to help out and thanks for the feedback. Please use code tags when posting to the Forum. Try:

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    05-18-2015
    Location
    America
    MS-Off Ver
    MS Office 2010
    Posts
    23

    Re: Macro that copies a row n number of times that is specified in a certain cell

    Ok, will do. And lastly if I wanted to change row B to the name "Actual Duration" would I just input that instead of B?

  8. #8
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Macro that copies a row n number of times that is specified in a certain cell

    I'm afraid I don't understand your question. The "B" in the code represents the Column you identified as "Duration". If you wanted for example to use Column "M" then you would change the "B" to "M"? Hope that answers your question.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. macro needed to repeat cell values for a specified number of times
    By genetist in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-15-2014, 06:54 AM
  2. [SOLVED] Macro to print number of copies equal to the output of a formula in a specific cell
    By Spencerk in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-21-2014, 03:54 PM
  3. Macro code which copies a specific number of digits only from one cell to another?
    By pagination1 in forum Excel Programming / VBA / Macros
    Replies: 25
    Last Post: 09-10-2013, 08:02 AM
  4. How to repeat a macro x number of times based on a value in a cell
    By gypsyhotelier in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-19-2011, 05:11 PM
  5. macro that copies a value from a cell at certain times
    By kagein in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-04-2009, 01:41 PM

Tags for this Thread

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