Insert multiple copied rows at fixed intervals

gizework 6 Posts Saturday February 24, 2018Registration date March 7, 2018 Last seen - Feb 26, 2018 at 01:36 AM - Latest reply: gizework 6 Posts Saturday February 24, 2018Registration date March 7, 2018 Last seen
- Mar 7, 2018 at 12:25 AM
Helo

Would you please help me by giving Solution for my Question how I can insert multiple copied rows n time at fixed interval using excel macros I thank you in advance for best cooperation.
See more 

Your reply

9 replies

TrowaD 2355 Posts Sunday September 12, 2010Registration dateModeratorStatus May 17, 2018 Last seen - Feb 26, 2018 at 12:23 PM
0
Helpful
Hi Gizework,

You aren't very specific. Give this code a try (it's just a start):
Sub RunMe()
Dim sRow As Range
Dim nTimes, fInterval, mLimit, x, y As Integer

Set sRow = Application.InputBox("Select row(s)", Type:=8)

nTimes = InputBox("How many times would you like to insert selected row(s)", "Repeat n times")
fInterval = InputBox("What is the fixed interval?:", "Input fixed interval")
mLimit = InputBox("Input the row you don't want to insert past:?")

Do
    y = y + fInterval
    For x = nTimes To 1 Step -1
        sRow.Copy
        Rows(y).Insert
    Next x
Loop While y < mLimit
End Sub


Best regards,
Trowa
gizework 6 Posts Saturday February 24, 2018Registration date March 7, 2018 Last seen - Feb 27, 2018 at 12:21 AM
I thank you for your help. It worked a little bit with what I intended, but please let me request you one more question what I perfectly need. In my previous question I said Fixed Interval, what i mean this, I want the copied rows to be pasted three or four rows below the selected copied rows and again below three or four rows the next inserted rows repeatedly until n times rows Inserted.. I thank you in advance for your best help.
Thanks for the information.
TrowaD 2355 Posts Sunday September 12, 2010Registration dateModeratorStatus May 17, 2018 Last seen - Feb 27, 2018 at 11:50 AM
Hi Gizework,

Could you provide some sample data? How it is now and how you want it to look.

Best regards,
Trowa
gizework 6 Posts Saturday February 24, 2018Registration date March 7, 2018 Last seen - Feb 28, 2018 at 02:02 PM
Hi Trowa
First of all I would like to thank you for your help and for giving me your time. Let the text that I want to copy and insert is Text A in first two rows. Then I need this will be copied like below.
A
1 TextA
2 TextA
3
4
5 Text A
6 TextA
7
8
9 Text A
10 TextA
11
12
13 TextA
14 TextA
.
.
.
Let the letter A on the top designate the excel column and the numbers from 1 up to 14 on the left side of the text designate the rows of excel and the gaps (the rows) that have no Text A is I think the fixed interval. The rows that I want to insert n times like above are 1 and 2 together($1:$2).

With best regards
Gizework
gizework 6 Posts Saturday February 24, 2018Registration date March 7, 2018 Last seen - Mar 6, 2018 at 12:53 AM
Hi Trowa
I am waiting for your answer. Excuse me since English Language is my second language it may be difficult for me to express my feeling that is why I may not be clear for you. if there is something which is not clear about my question you can tell me I will clarify for that. The reason why I need the solution for the above question is that in our company there is old payroll system that we used for several years. but using this payroll system It took us at least five days to provide payroll sheet and Payroll slip for more than one thousand employees per month that are Entering Individuals' absent days,Over time, Advance and Other Employees' Fields. However now we want to have new payroll system We have almost Developed the system. With this new System We could prepare the payroll sheet within one day so we could minimize four day what we did before. But the problem we faced here is that the payroll slip, to do this we have to export the payroll sheet to excel and inserting the individual Employees' field to each employees that is for one thousand Employees and then we do have Payroll slips which we can provide to our Employees. However what we faced here is we have to Insert the Employees' fields on the first two rows repeatedly on the above of the name and the amount of individual employees, the sample data may be similar with what I provide above that is " Text A".So Please I need your help, if you give me a help on this It will bring a lot change to our company Finance Dep't. I thank you in advance for you help.

with best regards

Gizework
Respond to TrowaD
TrowaD 2355 Posts Sunday September 12, 2010Registration dateModeratorStatus May 17, 2018 Last seen - Mar 6, 2018 at 11:12 AM
0
Helpful
Hi Gizework,

The following code will do as shown in your Text A post.

Here is the code:
Sub RunMe()
Dim x As Long
Rows("1:2").Copy

x = 5

Do
    Rows(x).PasteSpecial
    x = x + 4
Loop Until x > 14

Application.CutCopyMode = False
End Sub


Will that work for you?

Best regards,
Trowa
gizework 6 Posts Saturday February 24, 2018Registration date March 7, 2018 Last seen - Mar 7, 2018 at 12:25 AM
Hi Trowa
I Thank you very very much. It worked Perfectly.

with Best regards

Gizework
Respond to TrowaD