Split and create headings...I am so stuck! Shout out to Rick Rothstein---you've helped me so much!

CastingDirector

New Member
Joined
Jun 10, 2014
Messages
46
Several months ago Rick Rothstein gave me the greatest help...I've now lost the code (too many incarnations). I pray someone can help.
Previous thread link Mr Excel:
http://www.mrexcel.com/forum/excel-questions/852124-can-you-help-me-split-cell-use-first-part-new-row-heading.html

Here is a Before and after of what I am looking for. The Split in column E should create a heading with first part of split--listing the actors for that part (column c).

The second part of the split (string) should remain with the listed actor in the same row, column E.

As the code is now (above) it works the first time through but is messed up when other rows are copied onto the sheet or the sheet is viewed (activated when opened). I would like to add additional names via copy/past from other sheets to add to existing headings.
Arrgggg!

Any help is so gratefully acknowledged!

StatusActor NameAgentRole/Notes

From this: (Sorted in another sheet macro):
PASS07/21/15 4:26 PMActor CRep DataAlice/TV pilot
NAA-Tape07/21/15 4:26 PMActor HRep DataAlice/Will tape
NAA07/21/15 4:26 PMActor GRep DataBob/Has TV show
PASS07/21/15 4:26 PMActor ARep DataBob/Will tape
NAA07/21/15 5:05 PMActor FRep DataCarol/Can't leave town
NA07/21/15 4:26 PMActor ERep DataCarol/No to script
NA07/21/15 4:42 PMActor DRep DataTed/Has another project
NAA07/21/15 4:40 PMActor GRep DataBob/Has TV show
NA07/21/15 4:40 PMActor ERep DataCarol/No to script
PASS07/21/15 4:41 PMActor BRep DataTed/No to script
NAA-Tape07/21/15 4:42 PMActor IRep DataTed/No to script
To This:
Alice
PASS07/21/15 4:57 PMActor CRep DataTV pilot
NAA-Tape07/21/15 4:57 PMActor HRep DataWill tape
Bob
NAA07/21/15 4:57 PMActor GRep DataHas TV show
PASS07/21/15 4:57 PMActor ARep DataWill tape
Carol
NAA07/21/15 4:56 PMActor FRep DataCan't leave town
Ted
NA07/21/15 4:58 PMActor ERep DataNo to script
NA07/21/15 4:54 PMActor DRep DataHas another project
PASS07/21/15 4:54 PMActor BRep DataNo to script
NAA-Tape07/21/15 4:54 PMActor IRep DataNo to script
PASS07/21/15 4:54 PMActor CRep DataTV pilot
IF POSSIBLE ADD: (repeats those who indicate "will'' Tape")
Will TAPE
NAA-Tape07/21/15 4:54 PMActor HRep DataWill tape
PASS07/21/15 4:54 PMActor ARep DataWill tape
PASS07/21/15 5:00 PM

HERE IS THE CODE THAT ALMOST WORKS:
Actor ARep DataWill tape



Code:
[COLOR=blue]Sub[/COLOR] reorg()      
    [COLOR=blue]Dim[/COLOR] sh [COLOR=blue]As[/COLOR] Worksheet, lr [COLOR=blue]As[/COLOR] [COLOR=blue]Long[/COLOR], spl [COLOR=blue]As[/COLOR] [COLOR=blue]Variant[/COLOR], fn [COLOR=blue]As[/COLOR] Range, i [COLOR=blue]As[/COLOR] [COLOR=blue]Long[/COLOR] 
    [COLOR=blue]Set[/COLOR] sh = Sheet4 
    [COLOR=blue]With[/COLOR] Rows("7:99") 
        lr = sh.Cells(Rows.Count, "E").End(xlUp).Row 
        [COLOR=blue]For[/COLOR] i = lr [COLOR=blue]To[/COLOR] 2 [COLOR=blue]Step[/COLOR] -1 
            spl = Split(sh.Cells(i, 5).Value, "/") 
            [COLOR=blue]If[/COLOR] Application.CountIf(sh.Range("C:C"), Trim(spl([COLOR=blue]LBound[/COLOR](spl)))) > 0 [COLOR=blue]Then[/COLOR] [COLOR=#006400]'// Color Tag Removed[/COLOR]
                [COLOR=blue]Set[/COLOR] fn = sh.Range("C:C").Find(Trim(spl([COLOR=blue]LBound[/COLOR](spl))), , xlValues, xlWhole) 
                [COLOR=blue]With[/COLOR] fn 
                    .Font.Bold = [COLOR=blue]True[/COLOR] 
                    .Font.Size = 14 
                [COLOR=blue]End With[/COLOR] 
                [COLOR=blue]If[/COLOR] [COLOR=blue]Not[/COLOR] fn [COLOR=blue]Is[/COLOR] [COLOR=blue]Nothing[/COLOR] [COLOR=blue]Then[/COLOR] 
                    Rows(i).Copy 
                    fn.Offset(1, 0).EntireRow.Insert 
                    fn.Offset(1, 3) = Trim(spl([COLOR=blue]UBound[/COLOR](spl))) 
                    Rows(i).Delete 
                [COLOR=blue]End[/COLOR] [COLOR=blue]If[/COLOR] 
                 
            [COLOR=blue]Else[/COLOR] 
                sh.Rows(i).Insert 
                sh.Range("C" & i) = Trim(spl([COLOR=blue]LBound[/COLOR](spl))) 
                sh.Range("E" & i + 1) = Trim(spl([COLOR=blue]UBound[/COLOR](spl))) 
            [COLOR=blue]End[/COLOR] [COLOR=blue]If[/COLOR] 
        [COLOR=blue]Next[/COLOR] i 
    [COLOR=blue]End With[/COLOR] 
[COLOR=blue]End Sub[/COLOR]


<tbody>
</tbody>
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK

Forum statistics

Threads
1,216,028
Messages
6,128,383
Members
449,445
Latest member
JJFabEngineering

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