Vlookup Help

Boost

Board Regular
Joined
Jan 10, 2013
Messages
84
Hi All,

I am looking for help in changing a vlookup I am doing in the macro below. In step 5 I am looking at a 4 digit numeric code in Column E of the main worksheet(Ceridian) and dropping to a single worksheet (Department List) to lookup the number (in Column A) and copy the corresponding name (from Column B) back to the appropriate column (K) on the main worksheet. The info has all been from a department list worksheet.

I now need to look at the individual 2 letter code (In column D) to determine which of 3 department lists the lookup has to be conducted in. There is duplication of the 4 digit department numbers with different department names as a result. I also need it to go down the entire column and just go to the appropriate list for each row with a 2 letter code in D. The codes are CC for the "Dept List TCO" sheet, PA-TZ for the "Dept List Parish" sheet and SA-SW for the "Dept List School" Sheet. There is no longer a Department List sheet. Any suggestions on where to go from here would be greatly appreciated. Everything I have tried so far does just one condition (Parish) and leaves the others the same.

Thanks,
Barry





Option Explicit

Sub NamedRange()
'Create a named range for Step_5
Dim Rng1 As Range

Set Rng1 = Sheets("Department List").Range("A1:B613")
ActiveWorkbook.Names.Add Name:="Dept", RefersTo:=Rng1

End Sub
Sub AllSteps()
'Includes step 1 to 10
Dim x As String
Dim lr As Long
Dim i As Integer
Dim intRowCount As Integer
Dim ws As Worksheet
Dim fc As Worksheet
Dim r As Long
Dim lastRow As Long
Dim Dept As Range
Dim hds As Worksheet

'Set ls = Worksheets("Department List")
Set Dept = Sheets("Department List").Range("A1:B613")

Application.StatusBar = "This macro may take a few minutes to run.... please wait"

Application.ScreenUpdating = False

lr = Range("A" & Rows.Count).End(xlUp).Row
'Delete columns with commas in Step_1
Range("B1,D1,H1,J1").EntireColumn.Delete
'replace blanks with zeros Step_2
Range("F1:F" & lr).Select
Selection.Replace What:="", Replacement:="0", LookAt:=xlWhole
Range("F1").Select
Columns("F:F").Select
Selection.NumberFormat = "#,##0.00"

'Replace all (235910,235920,237000,238000)account numbers with '219030,219035,219050,219070'
Range("C1:C" & lr).Select
Selection.Replace What:="235910", Replacement:="219030", LookAt:=xlWhole
Selection.Replace What:="235920", Replacement:="219035", LookAt:=xlWhole
Selection.Replace What:="237000", Replacement:="219060", LookAt:=xlWhole
Selection.Replace What:="238000", Replacement:="219070", LookAt:=xlWhole


'Step_3, Step_4,
'Step_7, Step_8, Step_9 & Step_10 are combined within the 'Range("L" & i).Value = Range("D" & i).Value & etc... line
'Create_Balance_Sheet_Dept_01_0000_Step_3 & CopyDeptNames_ColumnJ_Step_4
'Formulas didnt trigger when tested, changed to vba
intRowCount = Range("A1").CurrentRegion.Rows.Count
For i = 1 To intRowCount
Select Case Range("C" & i).Value
Case 100000 To 299999
Range("I" & i).Value = "01-Oper:0000 Balance Sheet"
Range("J" & i).Value = "01-Oper:0000 Balance Sheet"
Range("L" & i).Value = Range("D" & i).Value & " " & Range("B" & i).Value
Range("M" & i).Value = Range("D" & i).Value & " " & Range("G" & i).Value & " " & Range("B" & i).Value
Case Else
Range("I" & i).Value = Range("E" & i).Value 'Changed from C to E
Range("J" & i).Value = Range("E" & i).Value 'Changed from C to E
Range("L" & i).Value = Range("D" & i).Value & " " & Range("B" & i).Value
Range("M" & i).Value = Range("D" & i).Value & " " & Range("G" & i).Value & " " & Range("B" & i).Value
End Select
Next i

'Format Column J Step_4
Columns("J:J").Select
With Selection
.HorizontalAlignment = xlLeft
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With

'Create named range (Code at top of this module)
NamedRange
'Create VlookUp and hardcode values Step_5 & Step_6
With Sheets("Ceridian File")
lastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
With .Range("K1:K" & lastRow)
.Formula = "=VLOOKUP(J1,Dept,2,0)"
.Value = .Value
End With
End With
'Replace all (not found in list - #N/A) errors with 'Not Found'
Range("K1:K" & lr).Select
Selection.Replace What:="#N/A", Replacement:="Not Found", LookAt:=xlWhole


'Copy_Entity_Names_to__IIF_Conversion_Sheet_Col_B_Step_12
Range("D1:D" & lr).Copy Destination:=Sheets("IIF Conversion").Range("B1")
Range("B1:B" & lr).Copy Destination:=Sheets("IIF Conversion").Range("D1")
Range("C1:C" & lr).Copy Destination:=Sheets("IIF Conversion").Range("E1")
Range("K1:K" & lr).Copy Destination:=Sheets("IIF Conversion").Range("F1") 'Changed from I to K
Range("F1:F" & lr).Copy Destination:=Sheets("IIF Conversion").Range("G1")
Range("M1:M" & lr).Copy Destination:=Sheets("IIF Conversion").Range("I1")

'CreateIFFSpecialColumns_SPL_and_GENERAL_JOURNAL Step_13
With Sheets("IIF Conversion")
lastRow = .Cells(.Rows.Count, "B").End(xlUp).Row
With .Range("A1:A" & lastRow)
.Formula = "=IF(ISBLANK(A1),"""",""SPL"")"
.Value = .Value
End With
End With

With Sheets("IIF Conversion")
lastRow = .Cells(.Rows.Count, "B").End(xlUp).Row
With .Range("C1:C" & lastRow)
.Formula = "=IF(A1=""SPL"",""GENERAL JOURNAL"","""")"
.Value = .Value
End With
End With
'Call sort macro, need to look at this
'Call IIF_Final_Presort_Step_14

'IIF_Final_Format_Prior_To_Sort Macro Step_15
Sheets("IIF Conversion").Select
Range("A1").Select
Selection.EntireRow.Insert
Selection.EntireRow.Insert
Selection.EntireRow.Insert
Set hds = ThisWorkbook.Sheets("Headers")
Set fc = ThisWorkbook.Sheets("IIF Conversion")
hds.Range("A1:I3").Copy fc.Range("A1")

'IIF_Conversion_Sheet_Data_Sort_Old_Procedure_Step_16A, no changes
Call IIF_Conversion_Sheet_Data_Sort_Old_Procedure_Step_16A

'Format all new ws
Call FormatWS_rs2k
'Resize columns to fit data
Columns("A:M").EntireColumn.Autofit


' Range("A1:J" & lr).Copy Destination:=Sheets("Working Sheet").Range("A1")
Application.ScreenUpdating = True
Application.StatusBar = False
End Sub

Sub FormatWS_rs2k()

Dim lr As Long
Dim ws As Worksheet
Dim hds As Worksheet
Dim i As Integer
Dim intRowCount As Integer

Application.ScreenUpdating = False

For Each ws In ActiveWorkbook.Sheets
If ws.Name <> "Sheet1" And ws.Name <> "Sheet2" And ws.Name <> "Sheet14" _
And ws.Name <> "Ceridian File" And ws.Name <> "Working Sheet" _
And ws.Name <> "Department List" And ws.Name <> "IIF Conversion" _
And ws.Name <> "Headers" And ws.Name <> "CC1" And ws.Name <> "PB-PP" _
And ws.Name <> "PQ-PV" And ws.Name <> "PW-QJ" And ws.Name <> "QK-QT" _
And ws.Name <> "QU-RE" And ws.Name <> "RF-RT" And ws.Name <> "RU-SC" _
And ws.Name <> "SD-SK" And ws.Name <> "SM-SS" And ws.Name <> "ST-TF" And ws.Name <> "TH-TZ" Then


ws.Select
'Add 'TRNS' & 'ENDTRNS' to Col A
ws.Range("A4").Value = "TRNS" 'This adds 'TRNS' to A4
'#### This changes all of column A to 'TRNS' ####################
' intRowCount = Range("A4").CurrentRegion.Rows.Count + 3
' For i = 1 To intRowCount
' ActiveCell.Value = "TRNS"
' ActiveCell.Offset(1, 0).Select
' Next i
'################################################################
lr = Range("A" & Rows.Count).End(xlUp).Row
ws.Range("A" & lr).Offset(1, 0).Value = "ENDTRNS"

'Add headers to new sheets
Set hds = ThisWorkbook.Sheets("Headers")
hds.Range("A1:I3").Copy ws.Range("A1")

'Move lr var to Col G and Total Col G
'lr = Range("G" & Rows.Count).End(xlUp).Row
'ws.Range("G" & lr).Offset(3, 0).Formula = WorksheetFunction.Sum(Range(Range("G5"), Range("G5").End(xlDown)))
lr = Range("G65536").End(xlUp).Row + 3
Cells(lr, 7).Formula = "=SUM(G4:G" & lr - 1 & ")"
Calculate
'Format 'Total Cell'
'ws.Range("G" & lr).Offset(3, 0).Select
ws.Range("G" & lr).Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 65535
.TintAndShade = 0
.PatternTintAndShade = 0
End With

ws.Range("A1").Select
End If
'Resize columns to fit data
ws.Range("A:I").EntireColumn.Autofit
Next ws
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic = True
End Sub
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Please use Excel Jeanie (see link in my sig) to paste a few rows from each of the worksheets involved.
 
Upvote 0
Hi Phil,

Thanks for taking the time to look at this. I have been away for a week so I apologize for the delay in getting back. I have gone to your link and the Excel Jeanie link for version 4.8 is in German. When I look for the English version I get 4.2. I am running Excel 2010 on windows 8.1 and am not sure what the issue is, but while I get EJ to be listed under the add-ins, it does not show up even after numerous reloads. In any event, here is what I am looking at:

This would be the Dept List School worksheet columns A and B
01-Oper:0000 Balance Sheet
01-Oper:0000 Balance Sheet
9000
01-Oper:Admin:9000 Gen
9010
01-Oper:Admin:9010 Pres
9020
01-Oper:Admin:9020 Princ
9030
01-Oper:Admin:9030 Bus
9040
01-Oper:Admin:9040 Min
9050
01-Oper:Admin:9050 Nurse

<colgroup><col style="mso-width-source:userset;mso-width-alt:6257;width:132pt" width="176"> <col style="mso-width-source:userset;mso-width-alt:682;width:14pt" width="19"> <col style="mso-width-source:userset;mso-width-alt:10922;width:230pt" width="307"> </colgroup><tbody>
</tbody>


This would be the Dept List Parish worksheet

01-Oper:0000 Balance Sheet
01-Oper:0000 Balance Sheet
1000
01-Oper:1000 Pastoral
1310
01-Oper:1310 Pastoral-Family Life
1480
01-Oper:1480 Pastoral-Peace&Justice
1518
01-Oper:1518 Pastoral-Rectory
1520
01-Oper:1520 Pastoral-Religious
2567
01-Oper:2567 Lit/Worship-Seminarians
3525
01-Oper:3525 Formation-RCIA
6572
01-Oper:6572 Facility Mgmt-Transport
8532
01-Oper:8532 Dioc Middle Sch Rally
8534
01-Oper:8534 Dioc Youth Council
8536
01-Oper:8536 Disciple Now Retreat
8538
01-Oper:8538 Emerging Conference

<colgroup><col style="mso-width-source:userset;mso-width-alt:6257;width:132pt" width="176"> <col style="mso-width-source:userset;mso-width-alt:1308;width:28pt" width="37"> <col style="mso-width-source:userset;mso-width-alt:8504;width:179pt" width="239"> </colgroup><tbody>
</tbody>


And this would be the Department List worksheet (This was Dept List TCO)

01-Oper:0000 Balance Sheet
01-Oper:0000 Balance Sheet
1514
01-Oper:Catholic Schools:1514 Center City Schs Consortiu
1520
01-Oper:Catholic Schools:1520 Education Banquet
3519
01-Oper:Chancery - Moderator/Curia:3519 Conduct Review Board
3525
01-Oper:Chancery - Moderator/Curia:3525 DCCW
2567
01-Oper:Chancery - Vicar General:2567 Seminarians
6303
01-Oper:Records Mgmt & Archives:6303 Records Mgmt/Archives
6572
01-Oper:Tribunal:6572 Tribunal
8532
01-Oper:Special Programs:8532 Ruth Ragon Pier Charitable
9005
01-Oper:Special Programs:9005 Year of Faith Closing Exp
9050
01-Oper:Special Programs:9050 Lawsuit - Reilly
9055
01-Oper:Special Programs:9055 Lawsuit - EEOC Randall

<colgroup><col style="mso-width-source:userset;mso-width-alt:6684;width:141pt" width="188"> <col style="mso-width-source:userset;mso-width-alt:768;width:16pt" width="22"> <col style="mso-width-source:userset;mso-width-alt:14677;width:310pt" width="413"> </colgroup><tbody>
</tbody>

I just need the program to operate looking at the other 2 worksheets (Parish and Schools) and replace any department list names with the appropriate department list name based on the entity code in column F (it is column D after the commas are removed during formatting) in the Ceridian Worksheet (i.e. CC would be Department List, PE for Parish, etc) below. As an aside, the Schools list is just SA-SW and the Parish List worksheet (Pa-TZ) does not include SA-SW:

Ceridian File worksheet
CE,8/15/2014
,101300CC1520,-3161.82,PAYROLL81514
CE,8/15/2014
,203010CC1520,-578.46,PAYROLL81514
CE,8/15/2014,203050CC1520,-302.32,PAYROLL81514
CE,8/15/2014,203050CC1520,-252.5,PAYROLL81514
CE,8/15/2014,203060CC1520,-70.7,PAYROLL81514
CE,8/15/2014,203060CC1520,-59.05,PAYROLL81514
CE,8/15/2014,203150CC1520,-7.51,PAYROLL81514
CE,8/15/2014,204120CC1520,-41.67,PAYROLL81514
CE,8/15/2014,204130CC1520,-29.28,PAYROLL81514
CE,8/15/2014,219010CC1520,-12.36,PAYROLL81514
CE,8/15/2014,219030CC1520,-308.74,PAYROLL81514
CE,8/15/2014,219040CC1520,-8.25,PAYROLL81514
CE,8/15/2014,219040CC1520,-25.64,PAYROLL81514
CE,8/15/2014,219040CC1520,-672.44,PAYROLL81514
CE,8/15/2014,219050CC1520,-34.82,PAYROLL81514
CE,8/15/2014,602000CC1520,521.67,PAYROLL81514
CE,8/15/2014,602000CC1520,53.06,PAYROLL81514
CE,8/15/2014,602030CC1520,3214.76,PAYROLL81514
CE,8/15/2014,602030CC1520,326.91,PAYROLL81514
CE,8/15/2014,610000CC1520,252.5,PAYROLL81514
CE,8/15/2014,610100CC1520,59.05,PAYROLL81514
CE,8/15/2014,618100CC1520,34.82,PAYROLL81514
CE,8/15/2014,619100CC1520,308.74,PAYROLL81514
CE,8/15/2014,620000CC1520,8.25,PAYROLL81514
CE,8/15/2014,620000CC1520,25.64,PAYROLL81514
CE,8/15/2014,620000CC1520,672.44,PAYROLL81514
CE,8/15/2014,622000CC1520,12.36,PAYROLL81514
CE,8/15/2014,203050CC2567,-42.29,PAYROLL81514
CE,8/15/2014,203060CC2567,-9.89,PAYROLL81514
CE,8/15/2014,219010CC2567,-1.91,PAYROLL81514
CE,8/15/2014,219030CC2567,-52.71,PAYROLL81514
CE,8/15/2014,219040CC2567,-2.74,PAYROLL81514
CE,8/15/2014,219040CC2567,-8.55,PAYROLL81514
CE,8/15/2014,219040CC2567,-224.15,PAYROLL81514
CE,8/15/2014,602000CC2567,505.08,PAYROLL81514
CE,8/15/2014,602000CC2567,197.64,PAYROLL81514
CE,8/15/2014,610000CC2567,42.29,PAYROLL81514
CE,8/15/2014,610100CC2567,9.89,PAYROLL81514
CE,8/15/2014,619100CC2567,52.71,PAYROLL81514
CE,8/15/2014,620000CC2567,2.74,PAYROLL81514
CE,8/15/2014,620000CC2567,8.55,PAYROLL81514
CE,8/15/2014,620000CC2567,224.15,PAYROLL81514
CE,8/15/2014,622000CC2567,1.91,PAYROLL81514
CE,8/15/2014,101300CC3525,-669.01,PAYROLL81514
CE,8/15/2014,203010CC3525,-44.22,PAYROLL81514
CE,8/15/2014,203050CC3525,-65.66,PAYROLL81514
CE,8/15/2014,203050CC3525,-65.66,PAYROLL81514
CE,8/15/2014,203060CC3525,-15.36,PAYROLL81514
CE,8/15/2014,203060CC3525,-15.36,PAYROLL81514
CE,8/15/2014,203310CC3525,-264.75,PAYROLL81514
CE,8/15/2014,219030CC3525,-79.43,PAYROLL81514
CE,8/15/2014,219050CC3525,-2.75,PAYROLL81514
CE,8/15/2014,602075CC3525,847.2,PAYROLL81514
CE,8/15/2014,602075CC3525,211.8,PAYROLL81514
CE,8/15/2014,610000CC3525,65.66,PAYROLL81514
CE,8/15/2014,610100CC3525,15.36,PAYROLL81514
CE,8/15/2014,618100CC3525,2.75,PAYROLL81514
CE,8/15/2014,619100CC3525,79.43,PAYROLL81514
CE,8/15/2014,101300CC6572,-3390.5,PAYROLL81514
CE,8/15/2014,203010CC6572,-85.92,PAYROLL81514
CE,8/15/2014,203050CC6572,-236.57,PAYROLL81514
CE,8/15/2014,203050CC6572,-181.85,PAYROLL81514
CE,8/15/2014,203060CC6572,-55.33,PAYROLL81514
CE,8/15/2014,203060CC6572,-42.53,PAYROLL81514
CE,8/15/2014,203160CC6572,-0.45,PAYROLL81514
CE,8/15/2014,203160CC6572,-6,PAYROLL81514
CE,8/15/2014,203310CC6572,-40,PAYROLL81514
CE,8/15/2014,203700CC6572,-1,PAYROLL81514
CE,8/15/2014,204120CC6572,-62.5,PAYROLL81514
CE,8/15/2014,204130CC6572,-29.28,PAYROLL81514
CE,8/15/2014,219010CC6572,-8.81,PAYROLL81514
CE,8/15/2014,219030CC6572,-222.49,PAYROLL81514
CE,8/15/2014,219040CC6572,-6.87,PAYROLL81514
CE,8/15/2014,219040CC6572,-21.36,PAYROLL81514
CE,8/15/2014,219040CC6572,-560.38,PAYROLL81514
CE,8/15/2014,219050CC6572,-26.6,PAYROLL81514
CE,8/15/2014,602000CC6572,290.8,PAYROLL81514
CE,8/15/2014,602000CC6572,22.88,PAYROLL81514
CE,8/15/2014,602050CC6572,244.87,PAYROLL81514
CE,8/15/2014,602050CC6572,2407.96,PAYROLL81514
CE,8/15/2014,610000CC6572,181.85,PAYROLL81514
CE,8/15/2014,610100CC6572,42.53,PAYROLL81514
CE,8/15/2014,618100CC6572,26.6,PAYROLL81514
CE,8/15/2014,619100CC6572,222.49,PAYROLL81514
CE,8/15/2014,620000CC6572,6.87,PAYROLL81514
CE,8/15/2014,620000CC6572,21.36,PAYROLL81514
CE,8/15/2014,620000CC6572,560.38,PAYROLL81514
CE,8/15/2014,622000CC6572,8.81,PAYROLL81514
CE,8/15/2014,101300CC8532,-85.56,PAYROLL81514
CE,8/15/2014,203050CC8532,-5.81,PAYROLL81514
CE,8/15/2014,203050CC8532,-5.81,PAYROLL81514
CE,8/15/2014,203060CC8532,-1.36,PAYROLL81514
CE,8/15/2014,203060CC8532,-1.36,PAYROLL81514
CE,8/15/2014,203700CC8532,-1,PAYROLL81514
CE,8/15/2014,219050CC8532,-0.82,PAYROLL81514
CE,8/15/2014,602095CC8532,93.73,PAYROLL81514
CE,8/15/2014,610000CC8532,5.81,PAYROLL81514
CE,8/15/2014,610100CC8532,1.36,PAYROLL81514
CE,8/15/2014,618100CC8532,0.82,PAYROLL81514
CE,8/15/2014,203050CC9050,-18.24,PAYROLL81514
CE,8/15/2014,203060CC9050,-4.27,PAYROLL81514
CE,8/15/2014,219010CC9050,-0.85,PAYROLL81514
CE,8/15/2014,219030CC9050,-23.53,PAYROLL81514
CE,8/15/2014,219040CC9050,-1.37,PAYROLL81514
CE,8/15/2014,219040CC9050,-4.27,PAYROLL81514
CE,8/15/2014,219040CC9050,-112.07,PAYROLL81514
CE,8/15/2014,602000CC9050,290.8,PAYROLL81514
CE,8/15/2014,602000CC9050,22.88,PAYROLL81514
CE,8/15/2014,610000CC9050,18.24,PAYROLL81514
CE,8/15/2014,610100CC9050,4.27,PAYROLL81514
CE,8/15/2014,619100CC9050,23.53,PAYROLL81514
CE,8/15/2014,620000CC9050,1.37,PAYROLL81514
CE,8/15/2014,620000CC9050,4.27,PAYROLL81514
CE,8/15/2014,620000CC9050,112.07,PAYROLL81514
CE,8/15/2014,622000CC9050,0.85,PAYROLL81514
CE,8/15/2014,203050PB1520,-79.65,PAYROLL81514
CE,8/15/2014,203060PB1520,-1.08,PAYROLL81514
CE,8/15/2014,602015PB1520,75,PAYROLL81514
CE,8/15/2014,610000PB1520,4.65,PAYROLL81514
CE,8/15/2014,610100PB1520,1.08,PAYROLL81514
CE,8/15/2014,203050PC3525,-159.02,PAYROLL81514
CE,8/15/2014,203060PC3525,-2.11,PAYROLL81514
CE,8/15/2014,219010PC3525,-0.35,PAYROLL81514
CE,8/15/2014,219030PC3525,-11.25,PAYROLL81514
CE,8/15/2014,219040PC3525,-0.39,PAYROLL81514
CE,8/15/2014,219040PC3525,-1.21,PAYROLL81514
CE,8/15/2014,219040PC3525,-31.65,PAYROLL81514
CE,8/15/2014,602005PC3525,150,PAYROLL81514
CE,8/15/2014,610000PC3525,9.02,PAYROLL81514
CE,8/15/2014,610100PC3525,2.11,PAYROLL81514
CE,8/15/2014,619100PC3525,11.25,PAYROLL81514
CE,8/15/2014,620000PC3525,0.39,PAYROLL81514
CE,8/15/2014,620000PC3525,1.21,PAYROLL81514
CE,8/15/2014,620000PC3525,31.65,PAYROLL81514
CE,8/15/2014,622000PC3525,0.35,PAYROLL81514
CE,8/15/2014,101300PD2567,-542.49,PAYROLL81514
CE,8/15/2014,203010PD2567,-26.39,PAYROLL81514
CE,8/15/2014,203050PD2567,-38.19,PAYROLL81514
CE,8/15/2014,203050PD2567,-38.19,PAYROLL81514
CE,8/15/2014,203060PD2567,-8.93,PAYROLL81514
CE,8/15/2014,203060PD2567,-8.93,PAYROLL81514
CE,8/15/2014,219050PD2567,-1.6,PAYROLL81514
CE,8/15/2014,602075PD2567,616,PAYROLL81514
CE,8/15/2014,610000PD2567,38.19,PAYROLL81514
CE,8/15/2014,610100PD2567,8.93,PAYROLL81514
CE,8/15/2014,618100PD2567,1.6,PAYROLL81514
CE,8/15/2014,101300PE6572,-3609.38,PAYROLL81514
CE,8/15/2014,203010PE6572,-336.4,PAYROLL81514
CE,8/15/2014,203050PE6572,-245.86,PAYROLL81514
CE,8/15/2014,203050PE6572,-245.87,PAYROLL81514
CE,8/15/2014,203060PE6572,-57.5,PAYROLL81514
CE,8/15/2014,203060PE6572,-57.5,PAYROLL81514
CE,8/15/2014,203160PE6572,-6.35,PAYROLL81514
CE,8/15/2014,204120PE6572,-104.17,PAYROLL81514
CE,8/15/2014,219010PE6572,-7.52,PAYROLL81514
CE,8/15/2014,219030PE6572,-305.23,PAYROLL81514
CE,8/15/2014,219040PE6572,-5.5,PAYROLL81514
CE,8/15/2014,219040PE6572,-17.09,PAYROLL81514
CE,8/15/2014,219040PE6572,-448.31,PAYROLL81514
CE,8/15/2014,219050PE6572,-35.81,PAYROLL81514
CE,8/15/2014,602002PE6572,1562.76,PAYROLL81514
CE,8/15/2014,602030PE6572,1349.95,PAYROLL81514
CE,8/15/2014,602030PE6572,1157.02,PAYROLL81514
CE,8/15/2014,610000PE6572,245.87,PAYROLL81514
CE,8/15/2014,610100PE6572,57.5,PAYROLL81514
CE,8/15/2014,618100PE6572,35.81,PAYROLL81514
CE,8/15/2014,619100PE6572,305.23,PAYROLL81514
CE,8/15/2014,620000PE6572,5.5,PAYROLL81514
CE,8/15/2014,620000PE6572,17.09,PAYROLL81514
CE,8/15/2014,620000PE6572,448.31,PAYROLL81514
CE,8/15/2014,622000PE6572,7.52,PAYROLL81514
CE,8/15/2014,101300PE8532,-1776.89,PAYROLL81514
CE,8/15/2014,203010PE8532,-119.44,PAYROLL81514
CE,8/15/2014,203050PE8532,-127.32,PAYROLL81514
CE,8/15/2014,203050PE8532,-133.41,PAYROLL81514
CE,8/15/2014,203060PE8532,-29.77,PAYROLL81514
CE,8/15/2014,203060PE8532,-31.2,PAYROLL81514
CE,8/15/2014,204120PE8532,-25,PAYROLL81514
CE,8/15/2014,219030PE8532,-89.05,PAYROLL81514
CE,8/15/2014,219050PE8532,-18.29,PAYROLL81514
CE,8/15/2014,602055PE8532,1087.32,PAYROLL81514
CE,8/15/2014,602055PE8532,100,PAYROLL81514
CE,8/15/2014,602062PE8532,991.1,PAYROLL81514
CE,8/15/2014,610000PE8532,133.41,PAYROLL81514
CE,8/15/2014,610100PE8532,31.2,PAYROLL81514
CE,8/15/2014,618100PE8532,18.29,PAYROLL81514
CE,8/15/2014,619100PE8532,89.05,PAYROLL81514
CE,8/15/2014,101300PE1520,-1357.95,PAYROLL81514
CE,8/15/2014,203010PE1520,-197.34,PAYROLL81514
CE,8/15/2014,203050PE1520,-117.28,PAYROLL81514
CE,8/15/2014,203050PE1520,-117.28,PAYROLL81514
CE,8/15/2014,203060PE1520,-27.43,PAYROLL81514
CE,8/15/2014,203060PE1520,-27.43,PAYROLL81514
CE,8/15/2014,203310PE1520,-191.67,PAYROLL81514
CE,8/15/2014,204120PE1520,-25,PAYROLL81514
CE,8/15/2014,219010PE1520,-5.75,PAYROLL81514
CE,8/15/2014,219030PE1520,-143.75,PAYROLL81514
CE,8/15/2014,219040PE1520,-5.5,PAYROLL81514
CE,8/15/2014,219040PE1520,-17.09,PAYROLL81514
CE,8/15/2014,219040PE1520,-448.31,PAYROLL81514
CE,8/15/2014,219050PE1520,-16.87,PAYROLL81514
CE,8/15/2014,602030PE1520,1209.01,PAYROLL81514
CE,8/15/2014,602030PE1520,707.66,PAYROLL81514
CE,8/15/2014,610000PE1520,117.28,PAYROLL81514
CE,8/15/2014,610100PE1520,27.43,PAYROLL81514
CE,8/15/2014,618100PE1520,16.87,PAYROLL81514
CE,8/15/2014,619100PE1520,143.75,PAYROLL81514
CE,8/15/2014,620000PE1520,5.5,PAYROLL81514
CE,8/15/2014,620000PE1520,17.09,PAYROLL81514
CE,8/15/2014,620000PE1520,448.31,PAYROLL81514
CE,8/15/2014,622000PE1520,5.75,PAYROLL81514
CE,8/15/2014,101300PE3525,-1424.32,PAYROLL81514
CE,8/15/2014,203010PE3525,-139.31,PAYROLL81514
CE,8/15/2014,203050PE3525,-108.5,PAYROLL81514
CE,8/15/2014,203050PE3525,-108.5,PAYROLL81514
CE,8/15/2014,203060PE3525,-25.37,PAYROLL81514
CE,8/15/2014,203060PE3525,-25.38,PAYROLL81514
CE,8/15/2014,203310PE3525,-52.5,PAYROLL81514
CE,8/15/2014,219010PE3525,-5.25,PAYROLL81514
CE,8/15/2014,219030PE3525,-131.25,PAYROLL81514
CE,8/15/2014,219040PE3525,-5.5,PAYROLL81514
CE,8/15/2014,219050PE3525,-15.4,PAYROLL81514
CE,8/15/2014,602002PE3525,1750,PAYROLL81514
CE,8/15/2014,610000PE3525,108.5,PAYROLL81514
CE,8/15/2014,610100PE3525,25.38,PAYROLL81514
CE,8/15/2014,618100PE3525,15.4,PAYROLL81514
CE,8/15/2014,619100PE3525,131.25,PAYROLL81514
CE,8/15/2014,620000PE3525,5.5,PAYROLL81514
CE,8/15/2014,622000PE3525,5.25,PAYROLL81514
CE,8/15/2014,101300PE2567,-1324.46,PAYROLL81514
CE,8/15/2014,203010PE2567,-125.61,PAYROLL81514
CE,8/15/2014,203050PE2567,-97.37,PAYROLL81514
CE,8/15/2014,203050PE2567,-109.14,PAYROLL81514
CE,8/15/2014,203060PE2567,-22.78,PAYROLL81514
CE,8/15/2014,203060PE2567,-25.52,PAYROLL81514
CE,8/15/2014,219050PE2567,-13.81,PAYROLL81514
CE,8/15/2014,602002PE2567,512.4,PAYROLL81514
CE,8/15/2014,602087PE2567,189.93,PAYROLL81514
CE,8/15/2014,602087PE2567,1057.82,PAYROLL81514
CE,8/15/2014,610000PE2567,109.14,PAYROLL81514
CE,8/15/2014,610100PE2567,25.52,PAYROLL81514
CE,8/15/2014,618100PE2567,13.81,PAYROLL81514
CE,8/15/2014,101300SA9000,-952.62,PAYROLL81514
CE,8/15/2014,203010SA9000,-57.74,PAYROLL81514
CE,8/15/2014,203050SA9000,-67.83,PAYROLL81514
CE,8/15/2014,203050SA9000,-67.83,PAYROLL81514
CE,8/15/2014,203060SA9000,-15.86,PAYROLL81514
CE,8/15/2014,203060SA9000,-15.86,PAYROLL81514
CE,8/15/2014,219010SA9000,-3.28,PAYROLL81514
CE,8/15/2014,219030SA9000,-82.05,PAYROLL81514
CE,8/15/2014,219040SA9000,-5.5,PAYROLL81514
CE,8/15/2014,219040SA9000,-17.09,PAYROLL81514
CE,8/15/2014,219040SA9000,-448.31,PAYROLL81514
CE,8/15/2014,219050SA9000,-2.84,PAYROLL81514
CE,8/15/2014,602075SA9000,1094.05,PAYROLL81514
CE,8/15/2014,610000SA9000,67.83,PAYROLL81514
CE,8/15/2014,610100SA9000,15.86,PAYROLL81514
CE,8/15/2014,618100SA9000,2.84,PAYROLL81514
CE,8/15/2014,619100SA9000,82.05,PAYROLL81514
CE,8/15/2014,620000SA9000,5.5,PAYROLL81514
CE,8/15/2014,620000SA9000,17.09,PAYROLL81514
CE,8/15/2014,620000SA9000,448.31,PAYROLL81514
CE,8/15/2014,622000SA9000,3.28,PAYROLL81514
CE,8/15/2014,101300SA9020,-2121.8,PAYROLL81514
CE,8/15/2014,203010SA9020,-165.78,PAYROLL81514
CE,8/15/2014,203050SA9020,-153.58,PAYROLL81514
CE,8/15/2014,203050SA9020,-153.58,PAYROLL81514
CE,8/15/2014,203060SA9020,-35.92,PAYROLL81514
CE,8/15/2014,203060SA9020,-35.92,PAYROLL81514
CE,8/15/2014,204120SA9020,-10.42,PAYROLL81514
CE,8/15/2014,219010SA9020,-7.46,PAYROLL81514
CE,8/15/2014,219030SA9020,-186.56,PAYROLL81514
CE,8/15/2014,219040SA9020,-5.5,PAYROLL81514
CE,8/15/2014,219040SA9020,-17.09,PAYROLL81514
CE,8/15/2014,219040SA9020,-448.31,PAYROLL81514
CE,8/15/2014,219050SA9020,-21.89,PAYROLL81514
CE,8/15/2014,602070SA9020,2487.5,PAYROLL81514
CE,8/15/2014,610000SA9020,153.58,PAYROLL81514
CE,8/15/2014,610100SA9020,35.92,PAYROLL81514
CE,8/15/2014,618100SA9020,21.89,PAYROLL81514
CE,8/15/2014,619100SA9020,186.56,PAYROLL81514
CE,8/15/2014,620000SA9020,5.5,PAYROLL81514
CE,8/15/2014,620000SA9020,17.09,PAYROLL81514
CE,8/15/2014,620000SA9020,448.31,PAYROLL81514
CE,8/15/2014,622000SA9020,7.46,PAYROLL81514
CE,8/15/2014,101300SA9050,-236.65,PAYROLL81514
CE,8/15/2014,203010SA9050,-10,PAYROLL81514
CE,8/15/2014,203050SA9050,-16.56,PAYROLL81514
CE,8/15/2014,203050SA9050,-16.56,PAYROLL81514
CE,8/15/2014,203060SA9050,-3.87,PAYROLL81514
CE,8/15/2014,203060SA9050,-3.87,PAYROLL81514
CE,8/15/2014,219050SA9050,-12.05,PAYROLL81514
CE,8/15/2014,602047SA9050,267.08,PAYROLL81514
CE,8/15/2014,610000SA9050,16.56,PAYROLL81514
CE,8/15/2014,610100SA9050,3.87,PAYROLL81514
CE,8/15/2014,618100SA9050,12.05,PAYROLL81514
CE,8/15/2014,101300SB9000,-303.4,PAYROLL81514
CE,8/15/2014,203010SB9000,-27,PAYROLL81514
CE,8/15/2014,203050SB9000,-22.55,PAYROLL81514
CE,8/15/2014,203050SB9000,-22.56,PAYROLL81514
CE,8/15/2014,203060SB9000,-5.27,PAYROLL81514
CE,8/15/2014,203060SB9000,-5.28,PAYROLL81514
CE,8/15/2014,219010SB9000,-3.78,PAYROLL81514
CE,8/15/2014,219030SB9000,-27.28,PAYROLL81514
CE,8/15/2014,219040SB9000,-5.5,PAYROLL81514
CE,8/15/2014,219050SB9000,-0.95,PAYROLL81514
CE,8/15/2014,602075SB9000,363.75,PAYROLL81514
CE,8/15/2014,610000SB9000,22.56,PAYROLL81514
CE,8/15/2014,610100SB9000,5.28,PAYROLL81514
CE,8/15/2014,618100SB9000,0.95,PAYROLL81514
CE,8/15/2014,619100SB9000,27.28,PAYROLL81514
CE,8/15/2014,620000SB9000,5.5,PAYROLL81514
CE,8/15/2014,622000SB9000,3.78,PAYROLL81514
CE,8/15/2014,101300SB9050,-1377.45,PAYROLL81514
CE,8/15/2014,203010SB9050,-324.87,PAYROLL81514
CE,8/15/2014,203050SB9050,-114.28,PAYROLL81514
CE,8/15/2014,203050SB9050,-114.29,PAYROLL81514
CE,8/15/2014,203060SB9050,-26.73,PAYROLL81514
CE,8/15/2014,203060SB9050,-26.72,PAYROLL81514
CE,8/15/2014,219010SB9050,-5.53,PAYROLL81514
CE,8/15/2014,219030SB9050,-138.25,PAYROLL81514
CE,8/15/2014,219040SB9050,-5.5,PAYROLL81514
CE,8/15/2014,219050SB9050,-16.22,PAYROLL81514
CE,8/15/2014,602050SB9050,1843.33,PAYROLL81514
CE,8/15/2014,610000SB9050,114.29,PAYROLL81514
CE,8/15/2014,610100SB9050,26.72,PAYROLL81514
CE,8/15/2014,618100SB9050,16.22,PAYROLL81514
CE,8/15/2014,619100SB9050,138.25,PAYROLL81514
CE,8/15/2014,620000SB9050,5.5,PAYROLL81514
CE,8/15/2014,203050TY1520,1262.6,PAYROLL81514
CE,8/15/2014,203060TY1520,-2.9,PAYROLL81514
CE,8/15/2014,602020TY1520,200,PAYROLL81514
CE,8/15/2014,610000TY1520,12.4,PAYROLL81514
CE,8/15/2014,610100TY1520,2.9,PAYROLL81514
CE,8/15/2014,203050TY3525,-23.32,PAYROLL81514
CE,8/15/2014,203060TY3525,-5.44,PAYROLL81514
CE,8/15/2014,602087TY3525,375.88,PAYROLL81514
CE,8/15/2014,610000TY3525,23.32,PAYROLL81514
CE,8/15/2014,610100TY3525,5.44,PAYROLL81514
CE,8/15/2014,101300TY2567,-2882.32,PAYROLL81514
CE,8/15/2014,203010TY2567,-273.94,PAYROLL81514
CE,8/15/2014,203050TY2567,-211.9,PAYROLL81514
CE,8/15/2014,203050TY2567,-211.9,PAYROLL81514
CE,8/15/2014,203060TY2567,-49.56,PAYROLL81514
CE,8/15/2014,203060TY2567,-49.56,PAYROLL81514
CE,8/15/2014,204120TY2567,-50,PAYROLL81514
CE,8/15/2014,204130TY2567,-29.28,PAYROLL81514
CE,8/15/2014,219010TY2567,-10.49,PAYROLL81514
CE,8/15/2014,219030TY2567,-262.28,PAYROLL81514
CE,8/15/2014,219040TY2567,-9.08,PAYROLL81514
CE,8/15/2014,219040TY2567,-34.18,PAYROLL81514
CE,8/15/2014,219040TY2567,-448.31,PAYROLL81514
CE,8/15/2014,219050TY2567,-21.74,PAYROLL81514
CE,8/15/2014,602030TY2567,2040,PAYROLL81514
CE,8/15/2014,602075TY2567,1457,PAYROLL81514
CE,8/15/2014,610000TY2567,211.9,PAYROLL81514
CE,8/15/2014,610100TY2567,49.56,PAYROLL81514
CE,8/15/2014,618100TY2567,21.74,PAYROLL81514
CE,8/15/2014,619100TY2567,262.28,PAYROLL81514
CE,8/15/2014,620000TY2567,9.08,PAYROLL81514
CE,8/15/2014,620000TY2567,34.18,PAYROLL81514
CE,8/15/2014,620000TY2567,448.31,PAYROLL81514
CE,8/15/2014,622000TY2567,10.49,PAYROLL81514
CE,8/15/2014,101300TY6572,-1193.14,PAYROLL81514
CE,8/15/2014,203010TY6572,-13.12,PAYROLL81514
CE,8/15/2014,203050TY6572,-80.98,PAYROLL81514
CE,8/15/2014,203050TY6572,-80.98,PAYROLL81514
CE,8/15/2014,203060TY6572,-18.93,PAYROLL81514
CE,8/15/2014,203060TY6572,-18.94,PAYROLL81514
CE,8/15/2014,204120TY6572,-20.83,PAYROLL81514
CE,8/15/2014,219010TY6572,-3.98,PAYROLL81514
CE,8/15/2014,219030TY6572,-99.53,PAYROLL81514
CE,8/15/2014,219040TY6572,-5.5,PAYROLL81514
CE,8/15/2014,219040TY6572,-17.09,PAYROLL81514
CE,8/15/2014,219040TY6572,-448.31,PAYROLL81514
CE,8/15/2014,219050TY6572,-11.68,PAYROLL81514
CE,8/15/2014,602031TY6572,1327,PAYROLL81514
CE,8/15/2014,610000TY6572,80.98,PAYROLL81514
CE,8/15/2014,610100TY6572,18.94,PAYROLL81514
CE,8/15/2014,618100TY6572,11.68,PAYROLL81514
CE,8/15/2014,619100TY6572,99.53,PAYROLL81514
CE,8/15/2014,620000TY6572,5.5,PAYROLL81514
CE,8/15/2014,620000TY6572,17.09,PAYROLL81514
CE,8/15/2014,620000TY6572,448.31,PAYROLL81514
CE,8/15/2014,622000TY6572,3.98,PAYROLL81514
CE,8/15/2014,101300TY8532,-960,PAYROLL81514
CE,8/15/2014,203010TY8532,-146.81,PAYROLL81514
CE,8/15/2014,203050TY8532,-74.31,PAYROLL81514
CE,8/15/2014,203050TY8532,-74.31,PAYROLL81514
CE,8/15/2014,203060TY8532,-17.38,PAYROLL81514
CE,8/15/2014,203060TY8532,-17.38,PAYROLL81514
CE,8/15/2014,204120TY8532,-62.5,PAYROLL81514
CE,8/15/2014,204300TY8532,-50,PAYROLL81514
CE,8/15/2014,219010TY8532,-3.93,PAYROLL81514
CE,8/15/2014,219030TY8532,-98.33,PAYROLL81514
CE,8/15/2014,219040TY8532,-5.5,PAYROLL81514
CE,8/15/2014,219040TY8532,-17.09,PAYROLL81514
CE,8/15/2014,219040TY8532,-448.31,PAYROLL81514
CE,8/15/2014,219050TY8532,-11.54,PAYROLL81514
CE,8/15/2014,602030TY8532,1311,PAYROLL81514
CE,8/15/2014,610000TY8532,74.31,PAYROLL81514
CE,8/15/2014,610100TY8532,17.38,PAYROLL81514
CE,8/15/2014,618100TY8532,11.54,PAYROLL81514
CE,8/15/2014,619100TY8532,98.33,PAYROLL81514
CE,8/15/2014,620000TY8532,5.5,PAYROLL81514
CE,8/15/2014,620000TY8532,17.09,PAYROLL81514
CE,8/15/2014,620000TY8532,448.31,PAYROLL81514
CE,8/15/2014,622000TY8532,3.93,PAYROLL81514
CE,8/15/2014,101300TY8427,-2328.28,PAYROLL81514
CE,8/15/2014,203010TY8427,-118.23,PAYROLL81514
CE,8/15/2014,203050TY8427,-164.26,PAYROLL81514
CE,8/15/2014,203050TY8427,-54.13,PAYROLL81514
CE,8/15/2014,203060TY8427,-38.42,PAYROLL81514
CE,8/15/2014,203060TY8427,-12.68,PAYROLL81514
CE,8/15/2014,204120TY8427,-75,PAYROLL81514
CE,8/15/2014,219050TY8427,-23.97,PAYROLL81514
CE,8/15/2014,602087TY8427,873.31,PAYROLL81514
CE,8/15/2014,610000TY8427,54.13,PAYROLL81514
CE,8/15/2014,610100TY8427,12.68,PAYROLL81514
CE,8/15/2014,618100TY8427,23.97,PAYROLL81514

<colgroup><col style="mso-width-source:userset;mso-width-alt:796;width:17pt" width="22"> <col style="mso-width-source:userset;mso-width-alt:2474;width:52pt" width="70"> <col style="mso-width-source:userset;mso-width-alt:2446;width:52pt" width="69"> <col style="mso-width-source:userset;mso-width-alt:1109;width:23pt" width="31"> <col style="mso-width-source:userset;mso-width-alt:1792;width:38pt" width="50"> <col style="mso-width-source:userset;mso-width-alt:1080;width:23pt" width="30"> <col style="mso-width-source:userset;mso-width-alt:2787;width:59pt" width="78"> <col style="mso-width-source:userset;mso-width-alt:2218;width:47pt" width="62"> <col style="mso-width-source:userset;mso-width-alt:1536;width:32pt" width="43"> <col style="mso-width-source:userset;mso-width-alt:6684;width:141pt" width="188"> <col style="width:49pt" width="66"> <col style="width:48pt" span="2" width="64"> </colgroup><tbody>
</tbody>

<colgroup><col style="mso-width-source:userset;mso-width-alt:796;width:17pt" width="22"> <col style="mso-width-source:userset;mso-width-alt:2474;width:52pt" width="70"> <col style="mso-width-source:userset;mso-width-alt:2446;width:52pt" width="69"> <col style="mso-width-source:userset;mso-width-alt:1109;width:23pt" width="31"> <col style="mso-width-source:userset;mso-width-alt:1792;width:38pt" width="50"> <col style="mso-width-source:userset;mso-width-alt:2787;width:59pt" width="78"> <col style="mso-width-source:userset;mso-width-alt:2218;width:47pt" width="62"> <col style="mso-width-source:userset;mso-width-alt:1536;width:32pt" width="43"> <col style="mso-width-source:userset;mso-width-alt:6684;width:141pt" width="188"> <col style="width:49pt" width="66"> <col style="width:48pt" span="2" width="64"> </colgroup><tbody>
</tbody>
 
Upvote 0
See comments in code.

Code:
Sub NamedRange()
    'Create named ranges for Step_5
    '## Uses CurrentRegion so it will change as needed when rows are added or deleted.
    ActiveWorkbook.Names.Add Name:="Dept", RefersTo:=Sheets("Department List").Range("A1").CurrentRegion
    ActiveWorkbook.Names.Add Name:="Schools", RefersTo:=Sheets("Department List School").Range("A1").CurrentRegion
    ActiveWorkbook.Names.Add Name:="Parish", RefersTo:=Sheets("Department List Parish").Range("A1").CurrentRegion
End Sub

Sub Revised_Step_5()

    'Assuming Ceredian Worksheet Columns are as follows after commas are removed:
    'A   B          C       D   E       F           G           H
    'CE  8/15/2014  101300  CC  1520    -3161.82    PAYROLL     81514
    
    'This code uses column D to determine which target worksheet
    '(Department List School, Department List Parish, Department List) to use
    'to lookup the code in column E and puts the result in column K

    Dim lastrow As Long
    
    NamedRange 'Updates named ranges for VLOOKUP targets
    
    'Revised Step 5
    With Sheets("Ceridian File")
        .AutoFilterMode = False
        lastrow = .Cells(.Rows.Count, "A").End(xlUp).Row

        'CC
        .Range("$A1:J" & lastrow).AutoFilter Field:=4, Criteria1:="CC"  'Entity Code
        If Application.WorksheetFunction.Subtotal(3, .Columns(1)) > 1 Then
            With .Range("K1:K" & lastrow).SpecialCells(xlCellTypeVisible)
                .Formula = "=VLOOKUP(E1,Dept,2,0)"
                '.Value = .Value    'Potential incorrect results while filter applied
            End With
        End If
        
        'Schools & Parish (temporarily for Schools)
        .Range("$A1:J" & lastrow).AutoFilter Field:=4, Criteria1:="<>CC"  'Entity Code
        If Application.WorksheetFunction.Subtotal(3, .Columns(1)) > 1 Then
            With .Range("K1:K" & lastrow).SpecialCells(xlCellTypeVisible)
                .Formula = "=VLOOKUP(E1,Parish,2,0)"
                '.Value = .Value    'Potential incorrect results if while applied
            End With
        End If
        
        'Schools (SA-SZ) (temporarily for SX-SZ))
        .Range("$A1:J" & lastrow).AutoFilter Field:=4, Criteria1:="=S*"  'Entity Code
        If Application.WorksheetFunction.Subtotal(3, .Columns(1)) > 1 Then
            With .Range("K1:K" & lastrow).SpecialCells(xlCellTypeVisible)
                .Formula = "=VLOOKUP(E1,Schools,2,0)"
                '.Value = .Value    'Potential incorrect results if while applied
            End With
        End If
        
        'SX,SY,SZ back to Parish if required
        .Range("$A1:J" & lastrow).AutoFilter Field:=4, Criteria1:= _
            Array("SX", "SY", "SZ"), Operator:=xlFilterValues           'Entity Code
        If Application.WorksheetFunction.Subtotal(3, .Columns(1)) > 1 Then
            With .Range("K1:K" & lastrow).SpecialCells(xlCellTypeVisible)
                .Formula = "=VLOOKUP(E1,Parish,2,0)"
                '.Value = .Value    'Potential incorrect results if while applied
            End With
        End If
    
        .AutoFilterMode = False
        
        With .Range("K1:K" & lastrow)
            .Value = .Value
        End With
        
    End With

End Sub

I marked a few statements in the AllSteps procedure with ## and made some comments. Combining statements and minimizing .Select actions will speed up your code.
Code:
Sub AllSteps()
    'Includes step 1 to 10
    
    Dim x As String
    Dim lr As Long
    Dim i As Integer
    Dim intRowCount As Integer
    Dim ws As Worksheet
    Dim fc As Worksheet
    Dim r As Long
    Dim lastrow As Long
    Dim Dept As Range
    Dim hds As Worksheet
    
    'Create named range (Code at top of this module)    ' ## Moved here to let Dept= line use named range as well
    NamedRange
    
    
    'Set ls = Worksheets("Department List")
    'Set Dept = Sheets("Department List").Range("A1:B613")   '## Replaced by next line
    Set Dept = Range("Dept")    'Will work assuming Named Range exists
    
    Application.StatusBar = "This macro may take a few minutes to run.... please wait"
    
    Application.ScreenUpdating = False
    
    '## This procedure assumes that you are starting with a particular worksheet active.
    '## Either guarantee it with a select statement or (preferred) use a With...End With block
    
    lr = Range("A" & Rows.Count).End(xlUp).Row
    
    If Range("B2").Value <> "," Then    '## to prevent deleting wrong rows
        'Delete columns with commas in Step_1
        Range("B1,D1,H1,J1").EntireColumn.Delete    ' ## In the Ceredian sheet you posted after I pasted, columns B,D,I,K contained commas
                                                    ' ## I modified the sheet I pasted to match this
        'replace blanks with zeros Step_2
        'Range("F1:F" & lr).Select                   '## Combined and replaced
        'Selection.Replace What:="", Replacement:="0", LookAt:=xlWhole      '## Combined and replaced
        Range("F1:F" & lr).Replace What:="", Replacement:="0", LookAt:=xlWhole
        
        'Range("F1").Select                         '## Not needed
        
        'Columns("F:F").Select                      '## Combined and replaced
        'Selection.NumberFormat = "#,##0.00"        '## Combined and replaced
        Columns("F:F").NumberFormat = "#,##0.00"    '## Select as little as possible.  Saves time
    End If
    
    'Replace all (235910,235920,237000,238000)account numbers with '219030,219035,219050,219070'
    With Range("C1:C" & lr) '## With Block
        .Replace What:="235910", Replacement:="219030", LookAt:=xlWhole
        .Replace What:="235920", Replacement:="219035", LookAt:=xlWhole
        .Replace What:="237000", Replacement:="219060", LookAt:=xlWhole
        .Replace What:="238000", Replacement:="219070", LookAt:=xlWhole
    End With
    
    'Step_3, Step_4,
    'Step_7, Step_8, Step_9 & Step_10 are combined within the 'Range("L" & i).Value = Range("D" & i).Value & etc... line
    'Create_Balance_Sheet_Dept_01_0000_Step_3 & CopyDeptNames_ColumnJ_Step_4
    'Formulas didnt trigger when tested, changed to vba
    
    intRowCount = Range("A1").CurrentRegion.Rows.Count
    For i = 1 To intRowCount
        Select Case Range("C" & i).Value
        Case 100000 To 299999
            Range("I" & i).Value = "01-Oper:0000 Balance Sheet"
            Range("J" & i).Value = "01-Oper:0000 Balance Sheet"
            Range("L" & i).Value = Range("D" & i).Value & " " & Range("B" & i).Value
            Range("M" & i).Value = Range("D" & i).Value & " " & Range("G" & i).Value & " " & Range("B" & i).Value
        Case Else
            Range("I" & i).Value = Range("E" & i).Value 'Changed from C to E
            Range("J" & i).Value = Range("E" & i).Value 'Changed from C to E
            Range("L" & i).Value = Range("D" & i).Value & " " & Range("B" & i).Value
            Range("M" & i).Value = Range("D" & i).Value & " " & Range("G" & i).Value & " " & Range("B" & i).Value
        End Select
    Next i
    
    'Format Column J Step_4
    'Columns("J:J").Select   '## Combined and replaced
    'With Selection          '## Combined and replaced
    With Columns("J:J")
        .HorizontalAlignment = xlLeft
        .VerticalAlignment = xlBottom
        .WrapText = False
        .Orientation = 0
        .AddIndent = False
        .IndentLevel = 0
        .ShrinkToFit = False
        .ReadingOrder = xlContext
        .MergeCells = False
    End With
    
    'Create VlookUp and hardcode values Step_5 & Step_6
'    With Sheets("Ceridian File")
'        lastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
'        With .Range("K1:K" & lastRow)
'            .Formula = "=VLOOKUP(J1,Dept,2,0)"
'            .Value = .Value
'        End With
'    End With
    
    'Revised Step 5
    With Sheets("Ceridian File")
        .AutoFilterMode = False
        lastrow = .Cells(.Rows.Count, "A").End(xlUp).Row

        'CC
        .Range("$A1:J" & lastrow).AutoFilter Field:=4, Criteria1:="CC"  'Entity Code
        If Application.WorksheetFunction.Subtotal(3, .Columns(1)) > 1 Then
            With .Range("K1:K" & lastrow).SpecialCells(xlCellTypeVisible)
                .Formula = "=VLOOKUP(E1,Dept,2,0)"
                '.Value = .Value    'Odd results when filter applied
            End With
        End If
        
        'Schools & Parish (temporarily for Schools)
        .Range("$A1:J" & lastrow).AutoFilter Field:=4, Criteria1:="<>CC"  'Entity Code
        If Application.WorksheetFunction.Subtotal(3, .Columns(1)) > 1 Then
            With .Range("K1:K" & lastrow).SpecialCells(xlCellTypeVisible)
                .Formula = "=VLOOKUP(E1,Parish,2,0)"
                '.Value = .Value    'Odd results when filter applied
            End With
        End If
        
        'Schools (SA-SZ) (temporarily for SX-SZ))
        .Range("$A1:J" & lastrow).AutoFilter Field:=4, Criteria1:="=S*"  'Entity Code
        If Application.WorksheetFunction.Subtotal(3, .Columns(1)) > 1 Then
            With .Range("K1:K" & lastrow).SpecialCells(xlCellTypeVisible)
                .Formula = "=VLOOKUP(E1,Schools,2,0)"
                '.Value = .Value    'Odd results when filter applied
            End With
        End If
        
        'SX,SY,SZ back to Parish if required
        .Range("$A1:J" & lastrow).AutoFilter Field:=4, Criteria1:= _
            Array("SX", "SY", "SZ"), Operator:=xlFilterValues           'Entity Code
        If Application.WorksheetFunction.Subtotal(3, .Columns(1)) > 1 Then
            With .Range("K1:K" & lastrow).SpecialCells(xlCellTypeVisible)
                .Formula = "=VLOOKUP(E1,Parish,2,0)"
                '.Value = .Value    'Odd results when filter applied
            End With
        End If
    
        .AutoFilterMode = False
        
        With .Range("K1:K" & lastrow)
            .Value = .Value
        End With
        
    End With
    
    
    
    'Replace all (not found in list - #N/A) errors with 'Not Found'
    'Range("K1:K" & lr).Select       '## Combined and replaced
    'Selection.Replace What:="#N/A", Replacement:="Not Found", LookAt:=xlWhole   '## Combined and replaced
    Range("K1:K" & lr).Replace What:="#N/A", Replacement:="Not Found", LookAt:=xlWhole
    
    
    'Copy_Entity_Names_to__IIF_Conversion_Sheet_Col_B_Step_12
    Range("D1:D" & lr).Copy Destination:=Sheets("IIF Conversion").Range("B1")
    Range("B1:B" & lr).Copy Destination:=Sheets("IIF Conversion").Range("D1")
    Range("C1:C" & lr).Copy Destination:=Sheets("IIF Conversion").Range("E1")
    Range("K1:K" & lr).Copy Destination:=Sheets("IIF Conversion").Range("F1") 'Changed from I to K
    Range("F1:F" & lr).Copy Destination:=Sheets("IIF Conversion").Range("G1")
    Range("M1:M" & lr).Copy Destination:=Sheets("IIF Conversion").Range("I1")
    
    'CreateIFFSpecialColumns_SPL_and_GENERAL_JOURNAL Step_13
    With Sheets("IIF Conversion")
        lastrow = .Cells(.Rows.Count, "B").End(xlUp).Row
        With .Range("A1:A" & lastrow)
            .Formula = "=IF(ISBLANK(A1),"""",""SPL"")"
            .Value = .Value
        End With
    End With
    
    With Sheets("IIF Conversion")
        lastrow = .Cells(.Rows.Count, "B").End(xlUp).Row
        With .Range("C1:C" & lastrow)
            .Formula = "=IF(A1=""SPL"",""GENERAL JOURNAL"","""")"
            .Value = .Value
        End With
    End With
    'Call sort macro, need to look at this
    'Call IIF_Final_Presort_Step_14
    
    'IIF_Final_Format_Prior_To_Sort Macro Step_15
    Sheets("IIF Conversion").Select
    
'    Range("A1").Select         '## Combined and replaced
'    Selection.EntireRow.Insert '## Combined and replaced
'    Selection.EntireRow.Insert '## Combined and replaced
'    Selection.EntireRow.Insert '## Combined and replaced
    Range("A1:C1").EntireRow.Insert
    
    Set hds = ThisWorkbook.Sheets("Headers")
    Set fc = ThisWorkbook.Sheets("IIF Conversion")
    hds.Range("A1:I3").Copy fc.Range("A1")
    
    'IIF_Conversion_Sheet_Data_Sort_Old_Procedure_Step_16A, no changes
    'Call IIF_Conversion_Sheet_Data_Sort_Old_Procedure_Step_16A
    
    'Format all new ws
    Call FormatWS_rs2k
    'Resize columns to fit data
    Columns("A:M").EntireColumn.AutoFit
    
    
    ' Range("A1:J" & lr).Copy Destination:=Sheets("Working Sheet").Range("A1")
    Application.ScreenUpdating = True
    Application.StatusBar = False
End Sub
 
Upvote 0
Thank you Phil for taking the time. Your help is greatly appreciated. I will work on this and let you know how it goes.
 
Upvote 0
Hi Phil,

I just wanted to get back to you and let you know that after a couple tweaks I got everything to work exactly the way I needed it to and your help was essential. I really appreciate all the time you spent helping, I couldn't have done it without you.

Thanks again,
Barry
 
Upvote 0
H Phil,

You helped me with the code above a couple years ago and it has been working great. Is there a way to change from 2 letter codes to 3 digit numeric codes for the entity names? I am hopimg it is something easy that I am overlooking. I don't mean to take any of your time, just hoping it is something easy like setting a parameter before changing them all.

Thanks,
Barry
 
Upvote 0
Sorry for the delay, I had not been checking my inbox for a while. I believe you should be able to make changes the Modified Step 5 in the AllSteps sub where autofilters are being applied to Field 4 (column D) an comparing them to various constants ("CC", "<>CC", "=S*", Array("SX", "SY", "SZ") to determine which formula to apply to column K. let me know if there are any other problems after you make those changes.
 
Upvote 0
Sorry for the delay, I had not been checking my inbox for a while. I believe you should be able to make changes the Modified Step 5 in the AllSteps sub where autofilters are being applied to Field 4 (column D) an comparing them to various constants ("CC", "<>CC", "=S*", Array("SX", "SY", "SZ") to determine which formula to apply to column K. let me know if there are any other problems after you make those changes.

Thanks for getting back to me, Phil. I appreciate all the help. I got everything straightened out and it has been working fine.
 
Upvote 0

Forum statistics

Threads
1,215,351
Messages
6,124,445
Members
449,160
Latest member
nikijon

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