Hello,
I was wondering if it was possible to insert 2 blank rows after a data change in a specific column (i.e. group the data), then to hide that column, and use the data entry as a title (in bold) for that group of data. For example;
Col A Col B
1234 Apple
5678 Apple
9876 Apple
1357 Pear
2468 Pear
9753 Pear
Would look like this:
Col A
Apple
1234
5678
9876
Pear
1357
2468
9753
I have found a code that inserts 2 rows after a data change, but not sure where to begin when trying to edit it to hide the data change column (D in this example) and to add the title to the 2nd new row:
Sub InsertRowAtChangeInValue()
Dim lRow As Long
For lRow = Cells(Cells.Rows.Count, "D").End(xlUp).Row To 2 Step -1
If Cells(lRow, "D") <> Cells(lRow - 1, "D") Then
Rows(lRow).EntireRow.Insert
Rows(lRow).EntireRow.Insert
End If
Next lRow
End Sub
Thanks for your help in anticipation!
PS. I'm using MS Excel 2013.
I was wondering if it was possible to insert 2 blank rows after a data change in a specific column (i.e. group the data), then to hide that column, and use the data entry as a title (in bold) for that group of data. For example;
Col A Col B
1234 Apple
5678 Apple
9876 Apple
1357 Pear
2468 Pear
9753 Pear
Would look like this:
Col A
Apple
1234
5678
9876
Pear
1357
2468
9753
I have found a code that inserts 2 rows after a data change, but not sure where to begin when trying to edit it to hide the data change column (D in this example) and to add the title to the 2nd new row:
Sub InsertRowAtChangeInValue()
Dim lRow As Long
For lRow = Cells(Cells.Rows.Count, "D").End(xlUp).Row To 2 Step -1
If Cells(lRow, "D") <> Cells(lRow - 1, "D") Then
Rows(lRow).EntireRow.Insert
Rows(lRow).EntireRow.Insert
End If
Next lRow
End Sub
Thanks for your help in anticipation!
PS. I'm using MS Excel 2013.