Gruppe
UDF
Problem
Der im Bereich B2:C3 genannte Zeitraum soll auf die Stunden gem. Zeile 1 aufgeteilt werden.
StandardModule: Modul1
Function SplitTime( _
datDStart As Date, _
datTStart As Date, _
datDEnd As Date, _
datTEnd As Date) As Integer
Dim arr(1 To 5) As Integer
Dim datStart As Date, datEnd As Date
Dim lHour As Long
datStart = datDStart + datTStart
datEnd = datDEnd + datTEnd
For lHour = datStart * 24 To (datEnd * 24) - 1
Select Case lHour Mod 24
Case Is < Range("D1").Value: arr(1) = arr(1) + 1
Case Is < Range("E1").Value: arr(2) = arr(2) + 1
Case Is < Range("F1").Value: arr(3) = arr(3) + 1
Case Is < Range("G1").Value: arr(4) = arr(4) + 1
Case Is < Range("H1").Value: arr(5) = arr(5) + 1
End Select
Next lHour
SplitTime = arr(Application.Caller.Column - 3)
End Function