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:
This manually adds 1 row to the bottom of the table.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
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
Last edited by Matt Parsons; 10-25-2011 at 05:55 AM.
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
Hi shg,
Thanks! That worked a treat - exactly what I was after!
Cheers,
Matt
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks