```
Dim Hrngel As Double, Hrngeh As Double
Dim Mrnge As Long, OOrnge As Long
Dim startRow As Long, endRow As Long, startCell As Long
With Worksheets("Price")
For k = 1 To y 'y = Number of Price criteria
For j = 1 To z - 1 'z-1 = Number of Proponents
startRow = k * z + 4 - z
endRow = k * z + 2
startCell = k * z + j + 3 - z
ThisWorkbook.Worksheets("Price").Range("B" & k * z + 3 + j - z).NumberFormat = "0.00"
Hrngel = FormatNumber(WorksheetFunction.Average(Range("B" & startRow & ":B" & endRow)) - WorksheetFunction.StDev(Range("B" & startRow & ":B" & endRow)), 2)
Hrngeh = FormatNumber(WorksheetFunction.Average(Range("B" & startRow & ":B" & endRow)) + WorksheetFunction.StDev(Range("B" & startRow & ":B" & endRow)), 2)
Mrnge = WorksheetFunction.Average(Range("B" & k * z + 4 - z & ":B" & (k * z) + 2))
OOrnge = (WorksheetFunction.CountIf(Range("J" & k * z + 4 - z & ":J" & (k * z) + 2), "No") - 1)
.Range(.Cells(startCell, 10), .Cells(startCell, 10)).Formula = "=IF(OR($B" & startCell & " < 2,$B" & startCell & " < " & Mrnge & " - 2,$B" & startCell & " > " & Mrnge & " + 2),""No"",""Yes"")"
.Range(.Cells(startCell, 6), .Cells(startCell, 6)).Formula = "=COUNTA(B" & startRow & ":B" & endRow & "),COUNTIFS(B" & startRow & ":B" & endRow & ", "">= 2"",B" & startRow & ":B" & endRow & ", ""<=""& " & Mrnge & " + 2,B" & startRow & ":B" & endRow & ", ""<""& B" & startCell & ")+1)"
'.Range(.Cells(startCell, 6), .Cells(startCell, 6)).Formula = "=IF(B" & startCell & " = ""Locked"","""",IF(OR($B" & startCell & " < 2,$B" & startCell & " < " & Mrnge & " - 2,$B" & startCell & " > " & Mrnge & " + 2)," & z - 1 & ",RANK.EQ($B" & startCell & ",B" & startRow & ":B" & (k * z) + 2 & ",1) - " & OOrnge & "))"
.Range(.Cells(startCell, 5), .Cells(startCell, 5)).Formula = "=IF(ISBLANK($B" & startCell & "),"""",IF($B" & startCell & " = ""Locked"","""",$C" & startCell & " * $D" & startCell & "/10))"
.Range(.Cells(startCell, 3), .Cells(startCell, 3)).Formula = "=IF(B" & startCell & " = ""Locked"","""",IF(OR($B" & startCell & " < 2,$B" & startCell & " < " & Mrnge & " - 2,$B" & startCell & " > " & Mrnge & " + 2),0,12 - 2 * $F" & startCell & "))"
ThisWorkbook.Worksheets("Price").Range("B" & k * z + 3 - z).FormulaArray = "=MIN(IF((B" & startRow & ":B" & endRow & " < " & Hrngeh & ") * (B" & startRow & ":B" & endRow & " > " & Hrngel & "),B" & startRow & ":B" & endRow & "))"
'ThisWorkbook.Worksheets("Price").Range("B" & k * z + 3 - z).Formula = "=MIN(B" & startRow & ":B" & endRow & ")"
Next j
Next k
End With
```