Insert a row with specific contents after every merged data cell.....

wolfwood

New Member
Joined
Jun 3, 2014
Messages
7
Hi all

I've looked online for VBA code to insert a row with specific contents (ex. 'Example1' after every merged data cell (it should check for data) in a specified range (B13:B269), but none seem to work properly with the merged cells. Column B has merged cells, but column D does not (Column C is blank, and non-merged).

So, it looks something like this:

Column B Column D
MergedCell1 Data1a
MergedCell1 Data1b
MergedCell2 Data2a
MergedCell2 Data2b
MergedCell3 Data3a
MergedCell3 Data3b

And after the code, I'd like it to look like this:

Column B Column D
MergedCell1 Data1a
MergedCell1 Data1b
Example1
MergedCell2 Data2a
MergedCell2 Data2b
Example2
MergedCell3 Data3a
MergedCell3 Data3b
Example3

If possible, I'd like this to apply to the whole workbook as every sheet is identical in terms of the number of rows.

Many thanks!

~J
 
Last edited:
Perhaps this:-

Rich (BB code):
.MergeArea(1).EntireRow.Insert
                .MergeArea(1).Offset(-1).Value = "example" & c
                .MergeArea(1).Offset(-1).Interior.ColorIndex = xlNone ' Add this line
            End If
 
Upvote 0

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

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