Inserting a new row when the data in the previous cell is not the same

Trentvano

New Member
Joined
Jun 15, 2013
Messages
2
I have data from hundreds of hours of a chat history between myself and a now deceased friend.

The columns are organized into date, screen name and message. When I paste it into word, each message is stacked on top of the other.

I would like for there to be a new row inserted whenever the screename changes, or that is to say, whenever the current "screen name" column is not equal to the "screen name" column immediately before it.


So here is how it looks now:

10/26/2009 TV Hello
10/26/2009 LG How are you
10/26/2009 TV I am fine
10/26/2009 TV How about you
10/26/2009 LG Oh good
10/26/2009 LG I am glad you are well
10/26/2009 LG hahaha

Here is how I need it:

10/26/2009 TV Hello
(SPACE)
10/26/2009 LG How are you
(SPACE)
10/26/2009 TV I am fine
10/26/2009 TV How about you
(SPACE)
10/26/2009 LG Oh good
10/26/2009 LG I am glad you are well
10/26/2009 LG hahaha

Thank you to anyone who can assist!!
 
Last edited:

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
some thing like below try

Before Macro

Excel Workbook
ABC
1DateScreen NameMessage
210/26/2009TVHello
310/26/2009LGHow are you
410/26/2009TVI am fine
510/26/2009TVHow about you
610/26/2009LGOh good
710/26/2009LGI am glad you are well
810/26/2009LGhahaha
Sheet2



After Macro

Excel Workbook
ABC
1DateScreen NameMessage
210/26/2009TVHello
3
410/26/2009LGHow are you
5
610/26/2009TVI am fine
710/26/2009TVHow about you
8
910/26/2009LGOh good
1010/26/2009LGI am glad you are well
1110/26/2009LGhahaha
Sheet2




Code:
Sub InsertRow()
Dim i As Integer
For i = Cells(Rows.Count, 1).End(xlUp).Row To 3 Step -1
    If Cells(i, 2) <> Cells(i - 1, 2) Then Cells(i, 2).EntireRow.Insert
Next
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,064
Messages
6,122,941
Members
449,094
Latest member
teemeren

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