Here is the code for the subroutine. I modified the code to just use Application.SumIfs I now get a "Type mismatch" error :
' Sub-routine is used to sum data from the segementation sheets and update the sorce sheet with the
' Summary values. It is called from the'subMAOP_Modify_Files_To_Add_HCA_Columns' subroutine
Sub subMAOP_Sum_Data(destWS As Worksheet, srcWB As Workbook, lngX As Long, srcWS As Worksheet)
On Error GoTo Err_ErrorCode
' Update stationing in the segmentation sheet
Dim varBegin As Variant, varLen As Variant, varEnd As Variant, varStart As Variant
Dim booCheck As Boolean, booFirst As Boolean, booHCA As Boolean, booFirstRow As Boolean
Dim rHL As Range, rNL As Range, rsrcValue As Range, rMAOP As Range, rC As Range ' Define new HCA column ranges
Dim destLastR As Range
Dim lngC As Long, lngY As Long, lngD As Long
Dim intI As Integer, intJ As Integer, intK As Integer
Dim varHLTotal As Variant, varNLTotal As Variant
Dim dblSum As Double
Dim strC As String, strHCA As String, strMAOP1 As String, strMAOP2 As String
Dim intCol As Integer
' Find Starting Row
booCheck = False
lngC = 1
Do Until booCheck
varStart = destWS.Range("C" & lngC).Value
If ThisWorkbook.Application.IsNumber(varStart) Then
booCheck = True
Else:
lngC = lngC + 1
End If
Loop
Set destLastR = destWS.Cells(Rows.Count, "C").End(xlUp)
lngD = destLastR.Row
'Get and update the rirst Row of Stationing
Set rC = destWS.Range("O" & lngC, "O" & lngD) ' Segmentation sheet Class Column
Set rHL = destWS.Range("EK:EK") ' Segmentation sheet HCA Length
Set rNL = destWS.Range("EL:EL") ' Segmentation sheet non-HCA Length
Set rMAOP = destWS.Range("AO" & lngC, "AO" & lngD) ' Segmentation sheet non-HCA Length
Set rsrcValue = srcWS.Range("A1")
rsrcValue.Cells(lngX, 14).Value = srcWS.Application.Sum(destWS.Range("C:C"))
intCol = 16
For intI = 1 To 4 ' For Classes 1 to 4
Select Case intI
Case Is = 1
strC = "Class I"
Case Is = 2
strC = "Class II"
Case Is = 3
strC = "Class III"
Case Is = 4
strC = "Class IV"
End Select
For intJ = 1 To 2 ' For HCA and Non-HCA
Select Case intJ
Case Is = 1
strHCA = "EK" ' Count HCA Length
Case Is = 1
strHCA = "EJ" ' Count non-HCA Length
End Select
For intK = 1 To 14 ' For each MAOP determining category
Select Case intK
Case Is = 1 ' Design Calculation
strMAOP1 = "Design Calculation - Original Class"
strMAOP2 = "Design Calculation - Current Class"
Case Is = 2 ' Design Calculation without records
strMAOP1 = "Unknown (Verified)"
strMAOP2 = ""
Case Is = 3 ' Pressure Test
strMAOP1 = "Pressure Test Pressure"
strMAOP2 = "Validation Pressure Test"
Case Is = 4 ' Pressure Test without records
strMAOP1 = "XXX"
strMAOP2 = "YYY"
Case Is = 5 ' Granfathered Pressure
strMAOP1 = "Grandfather Pressure"
strMAOP2 = "Certificated Pressure"
Case Is = 6 ' Grandfathered pressure without records
strMAOP1 = "XXX"
strMAOP2 = "YYY"
Case Is = 7 ' Operator Determined Pressure
strMAOP1 = "Operator Determined Pressure"
strMAOP2 = "XXX"
Case Is = 8 ' Operator Determined Pressure without Records
strMAOP1 = "XXX"
strMAOP2 = "YYY"
Case Is = 9 ' Grandfather High Pressure
strMAOP1 = "XXX"
strMAOP2 = "YYY"
Case Is = 10 ' Grandfather High Pressure without records
strMAOP1 = "XXX"
strMAOP2 = "YYY"
Case Is = 11 ' Alternative or special permit
strMAOP1 = "Alternative Pressure"
strMAOP2 = "Special Permit Pressure"
Case Is = 12 ' Alternative or special permit without records
strMAOP1 = "XXX"
strMAOP2 = "YYY"
Case Is = 13 ' Other method
strMAOP1 = "XXX"
strMAOP2 = "YYY"
Case Is = 14 ' Other method witout records
strMAOP1 = "XXX"
strMAOP2 = "YYY"
Case Else:
strMAOP1 = "<>XXX"
strMAOP2 = "<>YYY"
End Select
Select Case intJ
Case Is = 1
rsrcValue.Cells(lngX, intCol).Value = Application.SumIfs( _
arg1:=rHL, arg2:=rC, arg3:=strC, arg4:=rMAOP, arg5:=strMAOP1) + _
Application.SumIfs(arg1:=rHL, arg2:=rC, arg3:=strC, _
arg4:=rMAOP, arg5:=strMAOP2)
Case Is = 2
rsrcValue.Cells(lngX, intCol).Value = Application.SumIfs( _
arg1:=rNL, arg2:=rC, arg3:=strC, arg4:=rMAOP, arg5:=strMAOP1) + _
Application.SumIfs(arg1:=rNL, arg2:=rC, arg3:=strC, _
arg4:=rMAOP, arg5:=strMAOP2)
End Select
intCol = intCol + 1
Next intK
intCol = intCol + 1
Next intJ
intCol = intCol + 1
Next intI
Exit Sub
Exit_ErrorCode:
Exit Sub
Err_ErrorCode:
MsgBox Err.Description
Resume Exit_ErrorCode
End Sub