As jac said, it's because you're not checking first for a division by zero. I know that seems misleading because you're not getting that error, you're getting an Overflow.
As to why you're getting that instead of a division by zero is not something I'm awake enough to think deeply about, but simply checking first fixes the overflow. Here is an example resulting in an overflow followed by a working example with no errors:
Edit:### see very bottom showing how dividing TWO zeros results in an overflow, if one number is not 0 then it becomes a division by 0 error. Code at bottom.
Overflow error:
Image showing where overflow is occurring (can't upload, not enough reputation):
Click to view the image
Private Sub Form_Load()
Dim lTotOperMins As Long, KPIDown As Long
Dim lonDifference As Long
lTotOperMins = 0
KPIDown = 0
' Prevent / by 0
lonDifference = lTotOperMins - KPIDown
'If 0 = lonDifference Then
'Label1.Caption = Format(0, "#0.00")
'Else
Label1.Caption = Format(((lonDifference) / lTotOperMins) * 100, "#0.00")
'End If
End Sub
Working example:
Private Sub Form_Load()
Dim lTotOperMins As Long, KPIDown As Long
Dim lonDifference As Long
lTotOperMins = 0
KPIDown = 0
' Prevent / by 0
lonDifference = lTotOperMins - KPIDown
If 0 = lonDifference Then
Label1.Caption = "0.00"
Else
Label1.Caption = Format(((lonDifference) / lTotOperMins) * 100, "#0.00")
End If
End Sub
Dividing two zeros results in overflow error
Private Sub Form_Load()
Dim a As Long, b As Long
a = 0
b = 0
Debug.Print a / b
End Sub
Sections("Section5").Controls("lblcap").Caption = "0"?