Insert 4 Blank Rows in After Each Line

feroz_bilal

New Member
Joined
Jul 3, 2015
Messages
27
Hello,
I have data like this
a
b
c
d
e
f
g
h
i
j

<tbody>
</tbody>

And What I want to have is:

I would like to insert 4 blank lines after each line like this:

a
b
c

<tbody>
</tbody>
and so on....

Help will be highly appreciated.
Regards
 
@Rick

No, I wasn't implying your code would be slow.

I guess I was implying something like that it wouldn't work with a lot of rows.
I just looked at your use of the transpose operation, which won't work with Excel at least up to 2007 if more than about 65k rows.

So I tried your posted code on test data generated by a simple code
[a1].resize(x)="X"
with varying row numbers x, and timed our posted codes.
x=16000, Rick code 0.18 secs, kalak code 0.08 secs
x=20000, Rick code runtime error '13', kalak code 0.09 secs
x=200000, Rick code 0.10 secs, kalak code 0.58 secs

Interesting that your code seemed to work, and very very fast, with 200,000 rows but gave the error with 20,000. I'd expected another warning error message. However looking down the rows it seemed your code only produced gaps to about row 13564 and no gaps for the 182,000 or so after that.

I think your code was good for what it did, being both concise and fast.

But I have to ask, did you check that your code did in fact handle the 200,000 rows?
 
Upvote 0

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
@Rick

No, I wasn't implying your code would be slow.

I guess I was implying something like that it wouldn't work with a lot of rows.
You are absolutely right... my code does not work correctly (so it should be ignored and not considered)!

Thank you for pointing that out for me.
 
Upvote 0
Hello,
is there a way to add 3 blank rows after 2 rows, like this:

1
2
-
-
-
3
4
-
-
-

Regards
Like this?
Code:
Sub expand()

Dim a, b(), i, lr, x
lr = Cells(Rows.Count, 1).End(xlUp).Row
a = Columns(1).Resize(lr + 1)
ReDim b(1 To 8 * lr, 1 To 1)

For i = 1 To lr Step 2
    x = x + 5
    b(x - 4, 1) = a(i, 1)
    b(x - 3, 1) = a(i + 1, 1)
Next i

Cells(1).Resize(x) = b

End Sub
 
Upvote 0

Forum statistics

Threads
1,216,111
Messages
6,128,899
Members
449,477
Latest member
panjongshing

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top