+ Reply to Thread
Results 1 to 3 of 3

Thread: Creating x Number of Duplicate Rows

  1. #1
    Registered User
    Join Date
    01-12-2011
    Location
    Kent, England
    MS-Off Ver
    Excel 2007
    Posts
    9

    Creating x Number of Duplicate Rows

    Hello good people,

    I have started a project (in it's early stages) to keep track of customers and how much their orders come to each day. I have included a macro that copies and pastes a new row of data to the bottom of the spreadsheet, what I would like however is one that enters a set number of new lines based on the value of a cell. For instance, cell F5 contains the number of customers for that day, If it's value is 50 I would like the button 'New Row' to create 50 new rows.

    The macro code I have at the moment is as follows:

    Sub NewRow()
    ' NewRow Macro
    Sheets("Customers").Select
        Range("C9:N9").Copy
        Range("C1048576").Select
        Selection.End(xlUp).Select
        Selection.Offset(1, 0).Select
        ActiveSheet.Paste
    End Sub
    This manually adds 1 row to the bottom of the table.

    I know that I have to somehow store the number and loop the process x number of times but I can't figure out how to do this! Please help! I have attached the spreadsheet...

    Cheers,

    Matt
    Attached Files Attached Files
    Last edited by Matt Parsons; 10-25-2011 at 05:55 AM.

  2. #2
    Forum Guru shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2007, 2010
    Posts
    25,764

    Re: Creating x Number of Duplicate Rows

    Perhaps
    Sub NewRow()
        With Worksheets("Customers")
            .Range("C9:N9").Copy .Cells(.Rows.Count, "C").End(xlUp).Offset(1).Resize(Range("F5").Value)
        End With
    End Sub
    Microsoft MVP - Excel
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    01-12-2011
    Location
    Kent, England
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: Creating x Number of Duplicate Rows

    Hi shg,

    Thanks! That worked a treat - exactly what I was after!

    Cheers,

    Matt

+ 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.2.0