Copy And Insert Row N Times?
Jun 11, 2011
I need a macro that will copy a row to "n" number of identical rows below it, depending on user input. I am not skilled at VBA but I cobbled together some code I found online (see below). Unfortunately, it does not work properly. The input box pops up, but it only copies one new row regardless of what number you enter.
Sub InsertCopyRow2()
If vRows = 0 Then
vRows = Application.InputBox(prompt:= _
"How many rows do you want to add?", Title:="Add Rows", _
Default:=1, Type:=1) 'Default for 1 row, type 1 is number
If vRows = False Then Exit Sub
End If
ActiveCell.Offset(1, 0).EntireRow.Insert
ActiveCell.EntireRow.Copy ActiveCell.Offset(1, 0).EntireRow
End Sub
View 9 Replies
ADVERTISEMENT
Feb 6, 2008
The following code inserts a row below the selected row, and copies the formula of the row above into it.
Dim Rw As Integer
Rw = ActiveCell.Row
Selection.Insert Shift:=xlDown
Rows("" & Rw - 1 & ":" & Rw - 1 & "").Copy
Rows("" & Rw & ":" & Rw & "").Paste
However, I need to alter this to work for inserting more than one row at a time. ie. the user selects 'x' number of rows and 'x' rows are inserted below (in the same way 'Insert Row' works in Excel) and the row above the selection is copied down.
View 2 Replies
View Related
Feb 13, 2007
I have a column named "Time" and when I enter the data in the first row (for instance 6:00), I would like time to be inserted in the rows below in 5 minute increments.
But as an addition, I would like an input box that requires the end time. For instance, if I enter 6:00 in the first row, I should have a input box requesting me to enter end time. If I enter let's say 8:00, then time (in 5 minute increments) should be entered until time is 8:00.
Is it possible to do this in Excel? If it is, how would I go about it?
View 10 Replies
View Related
Jan 1, 2009
I need to work out a total of column A7:A39. Even with my lack of excel knowledge, I can do that with the sum formula. But, each week, I need to delete the values in A39 by deleting that row, and inserting a row into A7 and putting different data in.
I have my $ signs in place to make sure the formula relates to that column only, but when I insert the row at A7, the formula moves to A8:A39 not A7:A39. Basically I need to be able to delete and insert but still be able to view the sum of A7:A39 at all times.
View 4 Replies
View Related
Oct 19, 2013
I have a spreadsheet that has times in G column in military time. Some of the entries have "##:##" while others have "###" or "####" with no colons inserted.
I want to search through the g column and convert "###" to "#:##" and "####" to "##:##"
View 12 Replies
View Related
May 1, 2012
I have a sheet that contains the following columns:
Invoice, Document #, Date, PO #, Part #, Part Description, Quantity, Net Amount
Based on the quantity in the row I need to copy the row, and insert it n-1 times. So if the quantity is 5, I need to copy and insert the data below the original row 4 times for a total of 5 rows of data.
I plan on firing the macro with a button as the data will change month to month.
Using Windows 7 and Excel 2010
View 2 Replies
View Related
Sep 17, 2009
I have tried many different ways of coming up with a solution of this problem without writing a VBA program, however, Excel's date and time formatting scheme seem to be tripping me up. As a result, I am trying to figure out what direction to go.
I have seached the board up and down looking for a solution and I have found one problem that is midly similar but I do not fully understand the code. I have tried to modify it but to no avail.
Here is my problem:
I have 9 columns of data that are reported in 15 minute intervals for a little over 3 years. There are missing data in the data set and it would be infeasable for me to manually find and replace the missing data. (Over 110000 rows of data)
Example of data (Where "/" delienates column seperation):
Date / Temp 2m / Temp 10 m / Radiation / RH / WindAve / WindMax / WindMin / Rain
6-1-06 12:15 am / 45 / 35 / .0001 / 95 / 5 / 7 / 3 / 0
6-1-06 12:30 am / 45 / 35 / .0001 / 95 / 5 / 7 / 3 / 0
6-1-06 12:45 am / 45 / 35 / .0001/ 95 / 5 / 7 / 3 / 0
6-2-06 6:00 pm / 45 / 35 / .0001 / 95 / 5 / 7 / 3 / 0
6-2-06 6:15 pm / 45 / 35 / .0001 / 95 / 5 / 7 / 3 / 0
So what I need to do is this:
1) Find which data times are missing
2) Add the appropriate amount of rows in between where the missing data would be
3) Add the correct dates to the new rows
4) Add "N/A" to the columns that have no data
You can see that my date and time are formatted in mm/dd/yy hh:mm
I found this on the website and was trying to modify it to my needs:
Sub InsRow()
Dim c
View 9 Replies
View Related
Jan 10, 2007
I’m looking for a code which copies information from one worksheet to another and duplicates each row 3 times.
So for example on sheet 1 I’ve got data in C12-H12, C13-H13, C14-H14 etc.
The macro should copy the information C12-H12 to row 1,2 and 3 on the second sheet and than information from C13-H13 to row 4, 5 and 6 etc. Hope you understand what I’m trying to do.
I started with the following ...
View 9 Replies
View Related
May 7, 2014
Normally if you want to create a copy of a sheet what we do is :
Right click on the tab sheet > click on Move or copy > select (move to end) > check box Create a copy > click ok.
Now its very tedious if i have to copy the sheet lets say 50 times using this method. Perhaps there is another shorter way that will instantly create a copy of the sheet in the same workbook?
View 1 Replies
View Related
Oct 4, 2011
I'm trying to modify this line:
Range("A2").AutoFill Destination:=Range("A2:A10"), Type:=xlFillSeries
I trying to copy down a formula a set number of times based on a cell value or a declared value.
View 5 Replies
View Related
Jul 9, 2008
Is there a way in excel to have it automatically copy a cell 4 times and append _01, _02, etc..
ABCD0001
ABCD0002
and automatically make it look like this:
ABCD0001_01
ABCD0001_02
ABCD0001_03
ABCD0001_04
ABCD0002_01
ABCD0002_02
ABCD0002_03
ABCD0002_04
View 9 Replies
View Related
Jun 15, 2009
I'm trying to create an "export" feature where certain data can be copied out to a new workbook. I want to copy out the following from the current workbook to a new one: Sheets("1TR").Range("C33:M999") to range("A1") in the new workbook
and Sheets("1PL").Range("K33:K999") to range ("L1") in the new workbook.
The problem I'm having is that it is not just one copy/paste exercise, but two, and I don't know how to reference the new workbook as it doesn't have a filename.
View 4 Replies
View Related
Nov 18, 2009
I've attached below a small part of my code. I am wondering if there is a way to do this, without copying and pasting something 30 times, but using a loop instead. As you can see there are a series of productsNumbers (30 in total, but this example is for 3). Each productNumber is a string that is actually a 5 digit number, so it can be an integer as well, if it has to.
I would like to code below to loop for as many products as there may be. The way that I have it right now does not work - I feel that I am missing something small or that there is no way to do this.
View 3 Replies
View Related
Nov 28, 2008
I have some groups of data. Each group are 5 cells: ........
What I want is to make a formula to sum the five numbers of each group, then: =sum(a1:a5). but, how could I copy the formula to make Excel understand that I want the numbers from a6 to a 10, and from a11 to a16? I try to make it with left click in the square down at right, but it just add one value to each cell:
It makes this: ..................
View 2 Replies
View Related
Jul 31, 2012
I have a range A3:E70 where A3:E69 have the same formatting and the text in A70:E70 is bold. I want to copy-paste the entire range a number of times with a for ... next-loop. Actually, it's kind of a template system. I make the template A3:E70 and uses it a number of times.
View 2 Replies
View Related
Jul 9, 2013
I would like to copy the existing sheet "Template" 17 times and each of the copied sheet should be names according to the order in the array:
"XX","TT","YY","WE","TG","KJ","IO","RT","EF","VU","GF","DW","QA","EZ","QU","OF","BB"
how this is done in VBA?
View 3 Replies
View Related
Dec 18, 2013
I have created a userform with 4 textboxes and "ok" button. whenever I press OK I want it to copy TB1(text),TB2(number) and TB3(number) in the first empty row a number of times based on what is in TB4(number). however, each time it has to add 1 to TB2 and whenever (TB2+1) exceeds 5 then 1 is added to TB3 and TB2 start over from 1 again.
View 3 Replies
View Related
Jan 4, 2007
I have an excel sheet, Data's range is B2:B5.
The data is listed as follows: Tom, Pete, Steve, Lisa.
I need a VB code to copy and paste the names (range) to J2:J17. By having the names pasted four times each.
The result would look like this:
Tom
Tom
Tom
Tom
Pete
Pete
Pete
Pete
Etc.
View 9 Replies
View Related
May 7, 2008
I have a task which I am sure can be done quite simply. I have a list of names in column A and a number in column B. I want a Macro to copy the name in column c, d, e etc for the number in column b.
View 9 Replies
View Related
Mar 2, 2007
I am not good at writing codes and so would really appreciate if someone could help me.
I have a range suppose A1:D50 which i want to copy it certain no.of times, say around 50 times below the original range or in another sheet.
Can a code be created where I have a useform , where I will be entering the number for eg.50, which will copy the range 50 times below the original range or in new sheet.
View 9 Replies
View Related
Mar 20, 2009
Basically on the file below whenever there is data in column "type" I want excel to copy the "name" and "account" next to it. The whole file has about 80,000 rows. Spacing is not always one blank row between accounts. I am using excel 2007.
View 5 Replies
View Related
Mar 14, 2014
I have the price of S&P 500 in the L2 until L145 column.
And I would like to past each cell (L2, then L3, then L4....until L145) 220 times in column F.
As follow
L :
1780
1715
1680
.........(144 value)
TO column F
F:
1780
1780
1780
.........(220times)
1715
1715
1715
.........(220times)
1680
1680
1680
........(220times)
View 6 Replies
View Related
Mar 31, 2014
I have the following data in one "Project_list" tab:
Project
AAAA
BBBB
CCCC
DDDD
I want to copy this data into another tab "Transpose" in this form:
AAAA
AAAA
AAAA
AAAA
BBBB
BBBB
BBBB
BBBB
[code].....
So basically copying 4 times every row... as simple as that The constraint: I have about 1500+ projects in the project list, but this list can change so i need a statement that copy values 4 times till source tab has empty values. I would like to have in the second column the following serie for each project.
AAAA Q12014
AAAA Q22014
AAAA Q32014
AAAA Q42014
Note- i want to do this in VB not though formulas as i am doing other derivations in macro.
View 4 Replies
View Related
Jan 24, 2009
I'm trying to transpose multiple values in Excel, but I'd also like to repeat row values for columns A through E. The attached file "Raw Data" worksheet shows what I start with, and the "End Result" worksheet shows what I'd like the end result to be.
View 3 Replies
View Related
Oct 9, 2007
I have a range of cells that is 10 rows high. I want to copy and paste this range 11 times while identifying each of the 11 copies of the range, such as; 02,03,04...12.
Please see attachment for an example of what I am trying to do.
Does anyone have an idea of how this might be done in VB?
View 3 Replies
View Related
Jan 8, 2008
Is it possible to have the user inputing a value in cell $G$8 and have the range B11 to G11 to be copied x time depending the value of Cell $G$8 down. ie: Value is 5, it will be copied on 5 rows under B11 to G11??
View 3 Replies
View Related
Dec 4, 2009
Just curios if this is the most efficient way to copy a workbook x number of times.
I tried copying 77 workbooks and not sure exactly how long it took, but about 2 mintues. The original workbook is 300 KB.
View 7 Replies
View Related
Sep 30, 2013
I have a rand () which provides me a different number upon calculate. I would like to run a loop for 1000 times and take the value and copy and paste in a range.
The below sorta works, but at times it stops or doesn't work at all. I have a loop for the counter and the for each to place the value into the cell and have it run over and over and placing the value in the next cell underneath. I have the counter at 10 so I dont get stuck in some endless loop before I know it works.
Code:
Sub montecarlos()
Dim MCs As Long
Dim c As Range
Dim lCount As Long
Dim lNum As Long
lCount = 0
lNum = 1
Worksheets("MonteCarlo").Activate
[code].....
View 6 Replies
View Related
Jul 22, 2007
I enter a part number in "D1". The number of components required for that part number is returned in "G1" based on a VLookup. I would like a macro that will copy and paste the part number I enter in "D1" in the first empty cell in column "D" and will paste it once for each component (G1) required. For example, if the number of components required is 4, and the first empty cell in column "D" is "D10", I would like to paste the part number in cells "D10", "D11", "D12", and "D13".
View 2 Replies
View Related
Oct 12, 2007
Code copies the first two columns of a many column table and pastes them at a certain interval (14 columns) to make transfer to a report easy. The problem is that the worksheets each have a different number of columns, but none more than 56 columns. The macro works wonders on the first sheet, but thereafter does not work at all. The first sheet has 27 columns, the second sheet only has 4 columns and the one after has 38 or something.
Option Explicit
Public iMaleGroup As Integer
Public iFemaleGroup As Integer
Public iMaleAnimal As Integer
Public iFemaleAnimal As Integer
Public iMaleGroup1 As Integer
Public iFemaleGroup1 As Integer
Public StudyTitle As String
Public SmallAnimal As Boolean
Sub CommandModule()
Dim Wrkst As Worksheet
Dim wsName As String
Dim wsSubject As String
Dim wsNumber As String
Dim rSummaryHeader As Range
Dim MergedHeader
Dim NextMergedHeader
Dim HeaderRange
Dim AddHeader
Dim TableHeader
Dim SumTableHeader
Dim PasteRange
Dim x As Integer
Dim n As Integer
Dim z As Integer
Dim i As Integer
Application.Calculation = xlCalculationManual
Application. ScreenUpdating = False ............................
View 9 Replies
View Related