Public
Function
OpenLoop()
As
Double
Dim
wks
As
Worksheet
Dim
myRange
As
Range
Dim
Min
As
Double
Dim
Zelle
As
Range, ZeileStart
As
Variant
, ZeileEnd
As
Variant
Set
wks = ActiveSheet
With
wks
Set
myRange = .Range(.Cells(28, 2), .Cells(.Rows.Count, 2).
End
(xlUp))
Min = Application.WorksheetFunction.Min(myRange)
Zeile = Application.WorksheetFunction.Match(Min, myRange, 0)
Set
Zelle = myRange.Range(
"A1"
).Offset(Zeile - 1, 0)
ZeileStart = Zelle.Row
ZeileEnd = ZeileStart + 1
While
.Cells(ZeileEnd, 2) > -0.1
ZeileEnd = ZeileEnd + 1
Wend
ZeileEnd = ZeileEnd - 1
OpenLoop = Application.WorksheetFunction.Average(.Range(.Cells(ZeileStart, 3), .Cells(ZeileEnd, 3)))
End
With
End
Function