Usage example: FindMaxFromRange "B10:B155", 30
Function FindMaxFromRange(rng As Range, iPeriod As Integer) Dim cell As Range Dim i As Integer Dim val As Double Dim max As Double Dim imax As Integer i = 0 max = 0 imax = 0 For Each cell In rng i = i + 1 val = cell.Value If (i - imax) > iPeriod Then max = 0 End If If val > max Then max = val imax = i cell.BorderAround xlContinuous, xlThin, xlColorIndexAutomatic End If Next End Function
No comments:
Post a Comment