Sub M002_Calculate_Main_Sheet()
Dim ws As Worksheet
Dim a As Variant
Dim aM As Variant
Dim m As Long
Dim I As Long
Dim j As Long
Application.ScreenUpdating = False
Set ws = ThisWorkbook.Worksheets("sheet_mostgad")
m = ws.Cells(Rows.count, "C").End(xlUp).Row
a = ws.Range("E5:Z" & m + 3).Value
aM = Array("100", "100", "100", "100", "150", "150", "150", "150", "150", "100", "100", "100", "100", "100", "100", "150", "150", "150", "100", "", "", "100")
For I = LBound(a, 1) To UBound(a, 1) Step 4
For j = LBound(a, 2) To UBound(a, 2)
If j <> 20 And j <> 21 Then
a(I + 3, j) = "=Level($C" & I + 4 & ",IF(" & Chr(j + 68) & I + 5 & "=""""," & Chr(j + 68) & I + 4 & "," & Chr(j + 68) & I + 5 & ")," & Chr(j + 68) & "$3)"
If IsNumeric(a(I, j)) Then
If Val(aM(j - 1)) = 100 Then
If a(I, j) >= 48 And a(I, j) < 50 Then a(I + 2, j) = 50
ElseIf Val(aM(j - 1)) = 150 Then
If a(I, j) >= 72 And a(I, j) < 75 Then a(I + 2, j) = 75
End If
End If
End If
Next j
a(I, 22) = "=Quran(X" & I + 4 & ",Y" & I + 4 & ")"
Next I
With ws.Range("E5").Resize(UBound(a, 1), UBound(a, 2))
.Formula = a
End With
Application.ScreenUpdating = True
End Sub