 # Untitled

a guest
Jun 24th, 2017
135
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. Sub CalcWeightedEst()
2.     Dim i As Integer
3.     For i = 5 To 50
4.      Dim sum As Integer
5.      Dim avg As Double
6.      Dim distMeanOne As Double
7.      Dim distMeanTwo As Double
8.      Dim distMeanThree As Double
9.      Dim deviation As Double
10.
11.      sum = Cells(i, 2).Value + Cells(i, 3).Value + Cells(i, 4).Value
12.      avg = sum / 3
13.      If sum > 0 Then
14.        distMeanOne = Abs(Cells(i, 2).Value - avg) ^ 2
15.        distMeanTwo = Abs(Cells(i, 3).Value - avg) ^ 2
16.        distMeanThree = Abs(Cells(i, 4).Value - avg) ^ 2
17.        deviation = (distMeanOne + distMeanTwo + distMeanThree) / 3
18.        deviation = Sqr(deviation)
19.         If Cells(i, 5).Value = "Low" Then
20.           Cells(i, 6).Value = avg
21.         End If
22.         If Cells(i, 5).Value = "Medium" Then
23.           Cells(i, 6).Value = avg + (deviation * 1)
24.         End If
25.         If Cells(i, 5).Value = "High" Then
26.           Cells(i, 6).Value = avg + (deviation * 2)
27.         End If
28.
29.      End If
30.     Next i
31. End Sub
RAW Paste Data