I guess you need the program to install the formulae - I'll see what I can do.
Try this:
Sub Sumesh(): Dim d As Long, c As Long, r As Long
Dim F1 As String: F1 = "=IF(RC[-3]>RC[-4],""Y"",""N"")"
Dim F2 As String: F2 = "=SUM(RC[-6]-RC[-7])"
Dim F3 As String: F3 = "=AVERAGE(RC[-4]:RC[-1])"
Dim F4 As String: F4 = "=IF(RC[-4]>RC[-5],""Y"",""N"")"
Dim F5 As String: F5 = "=SUM(RC[-7]-RC[-8])"
r = Range("B" & Rows.count).End(xlUp).Row - 1
d = Range("A1") + 1: Range("A1") = d
If d = 4 Then
Cells(2, 7).Resize(r, 3).Formula = F1: Cells(2, 10).Resize(r, 3).Formula = F2
Cells(2, 17).Resize(r, 3).Formula = F1: Cells(2, 20).Resize(r, 3).Formula = F2
Cells(2, 27).Resize(r, 1).Formula = F3
Cells(2, 28).Resize(r, 3).Formula = F4: Cells(2, 31).Resize(r, 3).Formula = F5
Exit Sub: End If
If d = 5 Then
For c = 3 To 23 Step 10
Cells(2, c).Resize(r, 11).ClearContents
Range("A1") = 0: Next c
Else
For c = 3 To 23 Step 10
Cells(2, c + 1).Resize(r, 3).Value = _
Cells(2, c).Resize(r, 3).Value
Cells(2, c).Resize(r, 1).Value = "": Next c
End If
End Sub
Bookmarks