I have around 75 lines of code similar to the ones below. Each line can result in an error for multiple reasons (basically there's nothing to count or total). I cannot seem to find anything on the web that will show me how to add IFERROR in each line. Essentially, when there's an error b/c there's nothing to count or total, I just want the textbox value to be 0.
VBA Code:
Me.txt_PAppInSLA = WorksheetFunction.CountIfs(mP.Range("P:P"), Me.cobo_Assoc, mP.Range("T:T"), "Approved", mP.Range("AF:AF"), "In SLA", mP.Range("S:S"), ">=" & CDate(Me.txt_Start), mP.Range("S:S"), "<=" & CDate(Me.txt_End))
Me.txt_PConInSLA = WorksheetFunction.CountIfs(mP.Range("P:P"), Me.cobo_Assoc, mP.Range("T:T"), "Conditional Approved", mP.Range("AF:AF"), "In SLA", mP.Range("S:S"), ">=" & CDate(Me.txt_Start), mP.Range("S:S"), "<=" & CDate(Me.txt_End))
Me.txt_PDenInSLA = WorksheetFunction.CountIfs(mP.Range("P:P"), Me.cobo_Assoc, mP.Range("T:T"), "Denied", mP.Range("AF:AF"), "In SLA", mP.Range("S:S"), ">=" & CDate(Me.txt_Start), mP.Range("S:S"), "<=" & CDate(Me.txt_End))
Me.txt_PInSLAGT = WorksheetFunction.CountIfs(mP.Range("P:P"), Me.cobo_Assoc, mP.Range("AF:AF"), "In SLA", mP.Range("S:S"), ">=" & CDate(Me.txt_Start), mP.Range("S:S"), "<=" & CDate(Me.txt_End))
'Calcualtes the count of PRF decisions made outside of SLA.
Me.txt_PAppOutSLA = WorksheetFunction.CountIfs(mP.Range("P:P"), Me.cobo_Assoc, mP.Range("T:T"), "Approved", mP.Range("AF:AF"), "Out of SLA", mP.Range("S:S"), ">=" & CDate(Me.txt_Start), mP.Range("S:S"), "<=" & CDate(Me.txt_End))
Me.txt_PConOutSLA = WorksheetFunction.CountIfs(mP.Range("P:P"), Me.cobo_Assoc, mP.Range("T:T"), "Conditional Approved", mP.Range("AF:AF"), "Out of SLA", mP.Range("S:S"), ">=" & CDate(Me.txt_Start), mP.Range("S:S"), "<=" & CDate(Me.txt_End))
Me.txt_PDenOutSLA = WorksheetFunction.CountIfs(mP.Range("P:P"), Me.cobo_Assoc, mP.Range("T:T"), "Denied", mP.Range("AF:AF"), "Out of SLA", mP.Range("S:S"), ">=" & CDate(Me.txt_Start), mP.Range("S:S"), "<=" & CDate(Me.txt_End))
Me.txt_POutSLAGT = WorksheetFunction.CountIfs(mP.Range("P:P"), Me.cobo_Assoc, mP.Range("AF:AF"), "Out of SLA", mP.Range("S:S"), ">=" & CDate(Me.txt_Start), mP.Range("S:S"), "<=" & CDate(Me.txt_End))
'Calculates the total decisions made.
txt_PAppTotal = Val(Me.txt_PAppInSLA.value) + Val(Me.txt_PAppOutSLA.value)
txt_PConTotal = Val(Me.txt_PConInSLA.value) + Val(Me.txt_PConOutSLA.value)
txt_PDenTotal = Val(Me.txt_PDenInSLA.value) + Val(Me.txt_PDenOutSLA.value)
txt_PGT = Val(Me.txt_PInSLAGT.value) + Val(Me.txt_POutSLAGT.value)