Okay, thank-you. Let me try that again.
Option Compare Text
Sub Create_Security_List_v3()
Set wsSource = Worksheets("Registration")
Set wsTarget = Worksheets("Security List")
Set wsPart = Worksheets("Participant List")
Dim lastRow As Long
Application.ScreenUpdating = False
'Clear cells for the purpose of re-submitting security list
Range("A12:E111").ClearContents
wsSource.Activate
'Sort registration names alphabetically
Application.ScreenUpdating = False
Dim r As Range
Set r = wsSource.Cells(2, 6)
r.Select
wsSource.Sort.SortFields.Clear
wsSource.Sort.SortFields.Add Key:=r, SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With wsSource.Sort
.SetRange Range("A2", Range("A2").End(xlDown).End(xlToRight))
.Header = xlNo
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
'Sequential numbering for Registration Sheet
wsSource.Range("A2") = 1
wsSource.Range("A2").Select
Selection.DataSeries Rowcol:=xlColumns, Type:=xlLinear, Date:=xlDay, Step:=1, Stop:=Cells(Rows.Count, "A").End(xlUp).Row - 1, Trend:=False
'Move judicial officers to Security List by checking 'Position'
For i = 1 To Cells(Rows.Count, "C").End(xlUp).Row
If InStr(1, wsSource.Cells(i, 3).Value, "Magistrate") > 0 Then
With wsTarget
lastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
Cells(i, 1).Copy
.Cells(lastRow + 1, "A").PasteSpecial
Cells(i, 3).Copy
.Cells(lastRow + 1, "B").PasteSpecial
Cells(i, 8).Copy
.Cells(lastRow + 1, "C").PasteSpecial
Cells(i, 6).Copy
.Cells(lastRow + 1, "D").PasteSpecial
Cells(i, 2).Copy
.Cells(lastRow + 1, "E").PasteSpecial
End With
ElseIf InStr(1, wsSource.Cells(i, 3).Value, "Judge") > 0 Then
With wsTarget
lastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
Cells(i, 1).Copy
.Cells(lastRow + 1, "A").PasteSpecial
Cells(i, 3).Copy
.Cells(lastRow + 1, "B").PasteSpecial
Cells(i, 8).Copy
.Cells(lastRow + 1, "C").PasteSpecial
Cells(i, 6).Copy
.Cells(lastRow + 1, "D").PasteSpecial
Cells(i, 2).Copy
.Cells(lastRow + 1, "E").PasteSpecial
End With
ElseIf InStr(1, wsSource.Cells(i, 3).Value, "Justice") > 0 Then
With wsTarget
lastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
Cells(i, 1).Copy
.Cells(lastRow + 1, "A").PasteSpecial
Cells(i, 3).Copy
.Cells(lastRow + 1, "B").PasteSpecial
Cells(i, 8).Copy
.Cells(lastRow + 1, "C").PasteSpecial
Cells(i, 6).Copy
.Cells(lastRow + 1, "D").PasteSpecial
Cells(i, 2).Copy
.Cells(lastRow + 1, "E").PasteSpecial
End With
ElseIf InStr(1, wsSource.Cells(i, 3).Value, "Coroner") > 0 Then
With wsTarget
lastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
Cells(i, 1).Copy
.Cells(lastRow + 1, "A").PasteSpecial
Cells(i, 3).Copy
.Cells(lastRow + 1, "B").PasteSpecial
Cells(i, 8).Copy
.Cells(lastRow + 1, "C").PasteSpecial
Cells(i, 6).Copy
.Cells(lastRow + 1, "D").PasteSpecial
Cells(i, 2).Copy
.Cells(lastRow + 1, "E").PasteSpecial
End With
ElseIf InStr(1, wsSource.Cells(i, 3).Value, "Registrar") > 0 Then
With wsTarget
lastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
Cells(i, 1).Copy
.Cells(lastRow + 1, "A").PasteSpecial
Cells(i, 3).Copy
.Cells(lastRow + 1, "B").PasteSpecial
Cells(i, 8).Copy
.Cells(lastRow + 1, "C").PasteSpecial
Cells(i, 6).Copy
.Cells(lastRow + 1, "D").PasteSpecial
Cells(i, 2).Copy
.Cells(lastRow + 1, "E").PasteSpecial
End With
ElseIf InStr(1, wsSource.Cells(i, 3).Value, "Member") > 0 Then
With wsTarget
lastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
Cells(i, 1).Copy
.Cells(lastRow + 1, "A").PasteSpecial
Cells(i, 3).Copy
.Cells(lastRow + 1, "B").PasteSpecial
Cells(i, 8).Copy
.Cells(lastRow + 1, "C").PasteSpecial
Cells(i, 6).Copy
.Cells(lastRow + 1, "D").PasteSpecial
Cells(i, 2).Copy
.Cells(lastRow + 1, "E").PasteSpecial
End With
ElseIf InStr(1, wsSource.Cells(i, 3).Value, "President") > 0 Then
With wsTarget
lastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
Cells(i, 1).Copy
.Cells(lastRow + 1, "A").PasteSpecial
Cells(i, 3).Copy
.Cells(lastRow + 1, "B").PasteSpecial
Cells(i, 8).Copy
.Cells(lastRow + 1, "C").PasteSpecial
Cells(i, 6).Copy
.Cells(lastRow + 1, "D").PasteSpecial
Cells(i, 2).Copy
.Cells(lastRow + 1, "E").PasteSpecial
End With
End If
Next i
wsTarget.Activate
'Sequential numbering
'r = row, c = column
Application.Goto Reference:="R12C1"
Selection.End(xlDown).Select
Dim maxRowIndex As Integer
'-4 to account for the header row. Remove or adjust at will
maxRowIndex = ActiveCell.Row - 11
'set up starting point of repetition structure
Range("A12").Select
Dim rowCounter As Integer
rowCounter = 1
'begin populating sequence
For rowCounter = 1 To maxRowIndex
'populate number in sequence
ActiveCell = rowCounter
'go to next row
ActiveCell.Offset(1).Select
Next
'Copy program title
Dim lRow As Integer
With wsPart
lRow = wsTarget.Range("A5").CurrentRegion.Rows.Count
.Range("A5:F9").Copy wsTarget.Range("A5")
End With
'Changing the height of the empty rows
Rows(8).RowHeight = 10.5
'Hide blank 'program title' rows
Dim rngBlnk As Range
On Error Resume Next
Set rngBlnk = Range("A5:A7").SpecialCells(xlCellTypeBlanks)
On Error GoTo 0
If Not rngBlnk Is Nothing Then
rngBlnk.EntireRow.Hidden = True
End If
Application.ScreenUpdating = True
End Sub
Display More
Any assistance would be greatly appreciated.