Stared at this for some time and don't understand (sorry, quite new to this!):
If Slope <> PreviousSlope And PreviousSlope <> 0 Then
'Range(Range("B2:B102").Cells(i - 1), Range("B2:B102").Cells(IIf(PreviousSlope = 1, lastup, lastDown))).Offset(, 3).Value = IIf(PreviousSlope = 1, "Max", "Min")