[VBA] Add 2 rows for each non empty row in a range

Ideal Being

New Member
Joined
Mar 28, 2015
Messages
16
Hi,

I have a pretty simple problem, but my lack of VBA knowledge is preventing me from solving it. I already have VBA code which populates values from userform listbox into range B5:Jn (where n may be up to 1000, it would never be more). Range B4:J4 is preoccupied with headers.

What I need is another macro, which will (after populating values from userform) insert 2 empty rows (preferably with formatting taken from already populated rows) after each nonempty row (column C).

Current table:
Header1
Header2
Header3
Header4
1
A
2
B
C
3
D
4
E
F
G

<tbody>
</tbody>

Desired table:
Header1
Header2
Header3
Header4
1
A
2
B
C
3
D
4
E
F
G

<tbody>
</tbody>

I would be grateful for any piece of code which might do the trick.

Thanks everyone for your time and patience!
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Actually I just came up with nice-to-have enhancement. Instead of flat adding 2 rows I'd like to be able to have number in let's say Sheet1!F13 (the table from previous post is in let's say Sheet2) and the number -1 says how many rows should be added to table in Sheet2.
So if Sheet1!F13 = 3, then the macro should add 2 empty rows after each non empty row to table in Sheet2.

Hope I made myself clear..

Thanks again to anyone spending time with my problem!
 
Upvote 0

Forum statistics

Threads
1,214,638
Messages
6,120,676
Members
448,977
Latest member
moonlight6

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