NWE
04-09-2019, 10:26 AM
Hello All,
I am attempting to calculate a percent error with this code and I am not getting the right result. So the value in "A4" is -53, and should return a percent error of 75 percent. Any thoughts?
Sub CalculatePercentError()
'Calculate the errors in cells
Worksheets("Generalized Report").Activate
If Worksheets("Generalized Report").range("A4").Value = 0 Then 'Division by 0 error will occur
Worksheets("Generalized Report").range("A6").Value = Null
Else
Worksheets("Generalized Report").range("A6").Value = Abs(range("A4").Value \ (WorksheetFunction.Sum(Worksheets("Contract").range("H2:H10000")))) * 100
End If
End Sub
I am attempting to calculate a percent error with this code and I am not getting the right result. So the value in "A4" is -53, and should return a percent error of 75 percent. Any thoughts?
Sub CalculatePercentError()
'Calculate the errors in cells
Worksheets("Generalized Report").Activate
If Worksheets("Generalized Report").range("A4").Value = 0 Then 'Division by 0 error will occur
Worksheets("Generalized Report").range("A6").Value = Null
Else
Worksheets("Generalized Report").range("A6").Value = Abs(range("A4").Value \ (WorksheetFunction.Sum(Worksheets("Contract").range("H2:H10000")))) * 100
End If
End Sub