Split and create sorted headings from first part of string

CastingDirector

New Member
Joined
Jun 10, 2014
Messages
46
Hi and thank you. Here is the dilemma...I need to
Split the last column and create a heading from the first part of the split with the "/" as seperator.
Then sort the heading alphabetically.
I Have this:

[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]DATE[/TD]
[TD] NAME[/TD]
[TD]AGENT[/TD]
[TD]ROLE/NOTE[/TD]
[/TR]
[TR]
[TD]1/21/2015[/TD]
[TD]Actor A[/TD]
[TD]wm[/TD]
[TD]George/Likes script[/TD]
[/TR]
[TR]
[TD]1/22/2015[/TD]
[TD]Actor D[/TD]
[TD]ACA[/TD]
[TD]Bob/Cannot travel[/TD]
[/TR]
[TR]
[TD]2/22/2015[/TD]
[TD]Actor B[/TD]
[TD]caa[/TD]
[TD]Jimmy/Wife Pregnant[/TD]
[/TR]
[TR]
[TD]3/1/2015[/TD]
[TD]Actor E[/TD]
[TD]Wolf[/TD]
[TD]George/ Won't fly[/TD]
[/TR]
[TR]
[TD]12/2/2014[/TD]
[TD]Actor C[/TD]
[TD]Slick[/TD]
[TD]Jimmy/Working[/TD]
[/TR]
[TR]
[TD]12/21/2014[/TD]
[TD]Actor F[/TD]
[TD]wm[/TD]
[TD]Bob/will work for food[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]

I need this:
(Notice an added row to visually separate the "role" headings and if possible, make them bold.
Finally, new "Actors"will be added to the sheet multiple times via another pages' paste.)


[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]DATE[/TD]
[TD][/TD]
[TD] NAME[/TD]
[TD]AGENT[/TD]
[TD]ROLE/NOTE[/TD]
[/TR]
[TR]
[TD]BOB[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]1/22/2015[/TD]
[TD][/TD]
[TD]Actor B[/TD]
[TD]CAA[/TD]
[TD]Wife Pregnant[/TD]
[/TR]
[TR]
[TD]1/21/2015[/TD]
[TD][/TD]
[TD]Actor F[/TD]
[TD]wm[/TD]
[TD]Will work for food[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]GEORGE[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]1/21/2015[/TD]
[TD][/TD]
[TD]Actor A[/TD]
[TD]wm[/TD]
[TD]Likes script[/TD]
[/TR]
[TR]
[TD]3/1/2015[/TD]
[TD][/TD]
[TD]Actor E[/TD]
[TD]Wolf[/TD]
[TD]Won't Fly[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]JIMMY[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]2/22/2015[/TD]
[TD][/TD]
[TD]Actor B[/TD]
[TD]caa[/TD]
[TD]Wife Pregnant[/TD]
[/TR]
[TR]
[TD]12/2/2014[/TD]
[TD][/TD]
[TD]Actor C[/TD]
[TD]Slick[/TD]
[TD]Working[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]

I know this is alot and your help means the world to me
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
with your table starting in A1, does this do what you want?


Code:
Sub mrExcel10022015()
Dim x As Long


Application.ScreenUpdating = False


With Range("D2:D" & Range("D" & Rows.Count).End(xlUp).Row)
    .TextToColumns , xlDelimited, xlTextQualifierNone, False, False, False, False, False, True, "/"
    .CurrentRegion.Sort .Worksheet.Range("D1"), xlAscending, , , , , , xlYes
End With


For x = Range("D" & Rows.Count).End(xlUp).Row To 2 Step -1
    If StrComp(Range("D" & x).Value, Range("D" & x - 1).Value, vbTextCompare) <> 0 Then
        Range("D" & x).EntireRow.Insert
        With Range("A" & x)
            .Value = Range("D" & x + 1).Value
            .Font.Bold = True
        End With
    End If
Next x
Range("e2:e" & Range("e" & Rows.Count).End(xlUp).Row).Cut Range("D2")
End Sub
 
Upvote 0
Thanks so much. This runs but needs tweaking (on my part I'm sure). The sheet contains a date column (not mentioned in my post for clarity :\) The range is actually "E10:E99". It is a pretty easy fix for me and for that I am so grateful for your help!
 
Upvote 0
Thank you. I am an idiot as I did not mention that there is another column (not posted for example clarity ;\). The range is actually "E10:E99" and is an easy fix I'm sure. Thanks you so much.
SOLVED
 
Upvote 0
no problem let me know if you encounter difficulties
Hi,
I,m afraid I couldn't get this tweeked. The split cell does move into a bold heading into the new row as coded. The second part of the split, however, disappears completely and I need it to remain in the same position on the row. Also, when new data is added after the operation is performed, I am hoping that the row is inserted to the existing, established arrangement. Finally, the empty range begins in row 7 and is now starting above that. I guess I needed more assistance than I thought. I really appreciate your help.
 
Upvote 0

Forum statistics

Threads
1,223,243
Messages
6,170,971
Members
452,371
Latest member
Frana

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