ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   A Macro to Insert Rows (https://www.excelbanter.com/excel-discussion-misc-queries/218731-macro-insert-rows.html)

Confused_in_Houston[_2_]

A Macro to Insert Rows
 
I have repeating data in contiguous cells in a column. I want to insert a
row into the spreadsheet, each time a value in a cell below is not the same
as the value in the cell immediately above. This will create groupings of
identical values and a line between the groups.

What I have now:

AAAA
AAAA
AAAA
BBBB
BBBB
CCCC
DDDD

What a want:

AAAA
AAAA
AAAA

BBBB
BBBB

CCCC

DDDD

JB

A Macro to Insert Rows
 
http://cjoint.com/?cesAZcANHi

Sub insertRows()
i = 2
Do While i < [A65000].End(xlUp).Row
Do While Cells(i, 1) = Cells(i + 1, 1)
i = i + 1
Loop
Rows(i + 1).Insert
i = i + 2
Loop
End Sub

JB
http://boisgontierjacques.free.fr

On 2 fév, 17:25, Confused_in_Houston
wrote:
I have repeating data in contiguous cells in a column. *I want to insert a
row into the spreadsheet, each time a value in a cell below is not the same
as the value in the cell immediately above. *This will create groupings of
identical values and a line between the groups.

What I have now:

AAAA
AAAA
AAAA
BBBB
BBBB
CCCC
DDDD

What a want:

AAAA
AAAA
AAAA

BBBB
BBBB

CCCC

DDDD




All times are GMT +1. The time now is 12:25 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com