CastingDirector
New Member
- Joined
- Jun 10, 2014
- Messages
- 46
I would be so grateful for any/all help.
So here is the data BEFORE the sort macro (note actor A has corresponding notes in the same row (e)):
[TABLE="width: 705"]
<tbody>[TR]
[TD]NAA[/TD]
[TD]10/02/15[/TD]
[TD] Actor D[/TD]
[TD][/TD]
[TD]Carol|Notes on Actor D[/TD]
[/TR]
[TR]
[TD]NAA[/TD]
[TD]10/02/15[/TD]
[TD] Actor E[/TD]
[TD][/TD]
[TD]Ted|Notes on Actor E[/TD]
[/TR]
[TR]
[TD]NAA[/TD]
[TD]10/02/15[/TD]
[TD] Actor F[/TD]
[TD][/TD]
[TD]Ted|Notes on Actor F[/TD]
[/TR]
[TR]
[TD]NAA[/TD]
[TD]10/02/15[/TD]
[TD] Actor G[/TD]
[TD][/TD]
[TD]Bob|No Notes[/TD]
[/TR]
[TR]
[TD]NAA[/TD]
[TD]10/02/15[/TD]
[TD] Actor H[/TD]
[TD][/TD]
[TD]Ted|Notes on Actor H[/TD]
[/TR]
[TR]
[TD]NA[/TD]
[TD]10/02/15[/TD]
[TD] Actor C[/TD]
[TD][/TD]
[TD]Bob|Notes on Actor C[/TD]
[/TR]
[TR]
[TD]NAA[/TD]
[TD]10/02/15[/TD]
[TD] Actor A[/TD]
[TD][/TD]
[TD]Carol|Notes on A[/TD]
[/TR]
[TR]
[TD]PASS[/TD]
[TD]10/02/15[/TD]
[TD] Actor B[/TD]
[TD][/TD]
[TD]Alice|Notes on B[/TD]
[/TR]
</tbody>[/TABLE]
NOW AFTER THE CODE is processed with the macro:
[TABLE="width: 705"]
<tbody>[TR]
[TD][/TD]
[TD]Alice[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]NAA[/TD]
[TD]10/02/15[/TD]
[TD]Actor D[/TD]
[TD][/TD]
[TD]Notes on B[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]Bob[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]NAA[/TD]
[TD]10/02/15[/TD]
[TD]Actor E[/TD]
[TD][/TD]
[TD]No Notes[/TD]
[/TR]
[TR]
[TD]NAA[/TD]
[TD]10/02/15[/TD]
[TD]Actor F[/TD]
[TD][/TD]
[TD]Notes on Actor C[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]Carol[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]NAA[/TD]
[TD]10/02/15[/TD]
[TD]Actor G[/TD]
[TD][/TD]
[TD]Notes on A[/TD]
[/TR]
[TR]
[TD]NAA[/TD]
[TD]10/02/15[/TD]
[TD]Actor H[/TD]
[TD][/TD]
[TD]Notes on Actor D[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]Ted[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]NA[/TD]
[TD]10/02/15[/TD]
[TD]Actor C[/TD]
[TD][/TD]
[TD]Notes on Actor E[/TD]
[/TR]
[TR]
[TD]NAA[/TD]
[TD]10/02/15[/TD]
[TD]Actor A[/TD]
[TD][/TD]
[TD]Notes on Actor F[/TD]
[/TR]
[TR]
[TD]PASS[/TD]
[TD]10/02/15[/TD]
[TD]Actor B[/TD]
[TD][/TD]
[TD]Notes on Actor H[/TD]
[/TR]
</tbody>[/TABLE]
I am thrilled it works...except....what the?!? The notes in column E do not correspond to the actor?!?
Here is the code...can you see where I've gone wrong? Could really use your help. I promise to give back when I can!
So here is the data BEFORE the sort macro (note actor A has corresponding notes in the same row (e)):
[TABLE="width: 705"]
<tbody>[TR]
[TD]NAA[/TD]
[TD]10/02/15[/TD]
[TD] Actor D[/TD]
[TD][/TD]
[TD]Carol|Notes on Actor D[/TD]
[/TR]
[TR]
[TD]NAA[/TD]
[TD]10/02/15[/TD]
[TD] Actor E[/TD]
[TD][/TD]
[TD]Ted|Notes on Actor E[/TD]
[/TR]
[TR]
[TD]NAA[/TD]
[TD]10/02/15[/TD]
[TD] Actor F[/TD]
[TD][/TD]
[TD]Ted|Notes on Actor F[/TD]
[/TR]
[TR]
[TD]NAA[/TD]
[TD]10/02/15[/TD]
[TD] Actor G[/TD]
[TD][/TD]
[TD]Bob|No Notes[/TD]
[/TR]
[TR]
[TD]NAA[/TD]
[TD]10/02/15[/TD]
[TD] Actor H[/TD]
[TD][/TD]
[TD]Ted|Notes on Actor H[/TD]
[/TR]
[TR]
[TD]NA[/TD]
[TD]10/02/15[/TD]
[TD] Actor C[/TD]
[TD][/TD]
[TD]Bob|Notes on Actor C[/TD]
[/TR]
[TR]
[TD]NAA[/TD]
[TD]10/02/15[/TD]
[TD] Actor A[/TD]
[TD][/TD]
[TD]Carol|Notes on A[/TD]
[/TR]
[TR]
[TD]PASS[/TD]
[TD]10/02/15[/TD]
[TD] Actor B[/TD]
[TD][/TD]
[TD]Alice|Notes on B[/TD]
[/TR]
</tbody>[/TABLE]
NOW AFTER THE CODE is processed with the macro:
[TABLE="width: 705"]
<tbody>[TR]
[TD][/TD]
[TD]Alice[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]NAA[/TD]
[TD]10/02/15[/TD]
[TD]Actor D[/TD]
[TD][/TD]
[TD]Notes on B[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]Bob[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]NAA[/TD]
[TD]10/02/15[/TD]
[TD]Actor E[/TD]
[TD][/TD]
[TD]No Notes[/TD]
[/TR]
[TR]
[TD]NAA[/TD]
[TD]10/02/15[/TD]
[TD]Actor F[/TD]
[TD][/TD]
[TD]Notes on Actor C[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]Carol[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]NAA[/TD]
[TD]10/02/15[/TD]
[TD]Actor G[/TD]
[TD][/TD]
[TD]Notes on A[/TD]
[/TR]
[TR]
[TD]NAA[/TD]
[TD]10/02/15[/TD]
[TD]Actor H[/TD]
[TD][/TD]
[TD]Notes on Actor D[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]Ted[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]NA[/TD]
[TD]10/02/15[/TD]
[TD]Actor C[/TD]
[TD][/TD]
[TD]Notes on Actor E[/TD]
[/TR]
[TR]
[TD]NAA[/TD]
[TD]10/02/15[/TD]
[TD]Actor A[/TD]
[TD][/TD]
[TD]Notes on Actor F[/TD]
[/TR]
[TR]
[TD]PASS[/TD]
[TD]10/02/15[/TD]
[TD]Actor B[/TD]
[TD][/TD]
[TD]Notes on Actor H[/TD]
[/TR]
</tbody>[/TABLE]
I am thrilled it works...except....what the?!? The notes in column E do not correspond to the actor?!?
Here is the code...can you see where I've gone wrong? Could really use your help. I promise to give back when I can!
Code:
Option Explicit Sub CastingDirector()
Dim sh As Worksheet, LR As Long, spl As Variant, i As Long, r As Long
Dim NR As Long
Dim Arange As Range
Dim x As Long
Dim BR As Long
Set sh = Sheet4
NR = sh.Cells(Rows.Count, "E").End(xlUp).Row
For r = NR To 6 Step -1
If InStr(1, sh.Cells(r, 5).Value, "|") > 0 Then
Set Arange = Range("E6:E" & NR)
With Arange
.Sort Key1:=Arange, Order1:=xlAscending, Header:=False
End With
End If
Next
LR = sh.Cells(Rows.Count, "B").End(xlUp).Row
For i = LR To 6 Step -1
If sh.Cells(i, 5) Like "*|*" Then
spl = Split(sh.Cells(i, 5).Value, "|")
sh.Rows(i).Insert
sh.Range("B" & i) = Trim(spl(LBound(spl)))
With sh.Range("B" & i)
.Font.Bold = True
.Font.Size = 14
End With
sh.Range("E" & i + 1) = Trim(spl(UBound(spl)))
End If
Next
BR = Range("A350").End(xlUp).Row
For x = BR To 6 Step -1
If Application.WorksheetFunction.CountIf(Range("B6:B" & x), Range("B" & x).Text) > 1 Then
Range("A" & x).EntireRow.Delete
End If
Next x
End Sub