My Actual code is Like this:
Sub Maxvalues()
Application.ScreenUpdating = False
LR = Sheet1.Cells(Rows.Count, "A").End(xlUp).Row
For i = 4 To LR
If Range("A" & i) <> Range("A" & i - 1) Then
BeamRow = Sheet1.Cells(Rows.Count, "M").End(xlUp).Row + 1
Range("M" & BeamRow) = Range("A" & i)
End If
Next i
lastrow = Sheet1.Cells(Rows.Count, "M").End(xlUp).Row
On Error Resume Next
Range("E4:E" & LR & ",G4:G" & LR).SpecialCells(xlCellTypeConstants, 2).ClearContents
Sheet1.Range("N4:N" & lastrow).Formula = "=MAX(INDEX(($A$4:$A$" & LR & "=$M4)*($E$4:$E$" & LR & "),,))"
Sheet1.Range("O4:O" & lastrow).Formula = "=MAX(INDEX(($A$4:$A$" & LR & "=$M4)*($G$4:$G$" & LR & "),,))"
Sheet1.Range("P4:P" & lastrow).Formula = "=MIN(INDEX(($A$4:$A$" & LR & "=$M4)*($E$4:$E$" & LR & "),,))"
Sheet1.Range("Q4:Q" & lastrow).Formula = "=MIN(INDEX(($A$4:$A$" & LR & "=$M4)*($G$4:$G$" & LR & "),,))"
Sheet1.Range("R4:R" & lastrow).Formula = "=IF($N4<$O4,""MY"",IF($N4>$O4,""MZ"",""Same""))"
Sheet1.Range("X4:X" & lastrow).Formula = "=IF($P4>$Q4,""MY"",IF($P4<$Q4,""MZ"",""Same""))"
Sheet1.Range("S4:S" & lastrow).Formula = "=MAX(ABS(N" & ActiveCell.Row & "),ABS(O" & ActiveCell.Row & "))"
Sheet1.Range("U4:U" & lastrow).Formula = "=IF($P4>$Q4,""MY"",IF($P4<$Q4,""MZ"",""Same""))"
Sheet1.Range("Y4:Y" & lastrow).Formula = "=IF(MAX($N4:$Q4)>MIN($N4:$Q4)*-1,MAX($N4:$Q4),MIN($N4:$Q4))"
Range("V4").Select
Sheet1.Range("V4:V" & lastrow).Formula = "=0-MAX(ABS(P" & ActiveCell.Row & "),ABS(Q" & ActiveCell.Row & "))"
Sheet1.Range("X4:X" & lastrow).Formula = "=INDEX($N$3:$Q$3,MATCH($Y4,$N4:$Q4,0))"
Sheet1.Range("N4:Y" & lastrow).Value = Sheet1.Range("N4:Y" & lastrow).Value
Range("E4:E" & LR & ",G4:G" & LR).SpecialCells(xlCellTypeBlanks).Value = "N/A"
Application.ScreenUpdating = True
End Sub
Kindly modify and tweak if any to my present code as per Attached document.
Bookmarks