AW: Nachtrag
18.11.2008 14:49:00
Chris
servus,
und falls dich die Minuten auch nicht kratzen, dann so:
Sub t()
Dim i As Long, lngLetzte As Long, lngAnfang As Long, lngEnde As Long
Dim dbSumme As Double, merkAnfang As Long, merkEnde As Long
Dim rSuche As Range, rFinde As Range, strErste As String
lngLetzte = Cells(Rows.Count, 1).End(xlUp).Row
Set rFinde = Range("A1:A" & lngLetzte)
Set rSuche = rFinde.Find(what:="06:*", lookAt:=xlPart, LookIn:=xlValues)
If Not rSuche Is Nothing Then
strErste = rSuche.Address
merkAnfang = rSuche.Row
Do
lngAnfang = rSuche.Row
If lngAnfang > merkAnfang Then
lngAnfang = merkAnfang
End If
Set rSuche = rFinde.FindNext(rSuche)
Loop While Not rSuche Is Nothing And rSuche.Address strErste
Else
MsgBox "Es gibt keine Uhrzeit beginnend mit ""06:..."" !", vbExclamation, "Abbruch"
Exit Sub
End If
Set rSuche = rFinde.Find(what:="14:*", lookAt:=xlPart, LookIn:=xlValues)
If Not rSuche Is Nothing Then
strErste = rSuche.Address
merkEnde = rSuche.Row
Do
lngEnde = rSuche.Row
If lngEnde > merkEnde Then
lngEnde = merkEnde
End If
Set rSuche = rFinde.FindNext(rSuche)
Loop While Not rSuche Is Nothing And rSuche.Address strErste
Else
MsgBox "Es gibt keine Uhrzeit beginnend mit ""14:..."" !", vbExclamation, "Abbruch"
Exit Sub
End If
If lngAnfang 0 And lngEnde 0 Then
dbSumme = Application.WorksheetFunction.Sum(Range("G" & lngAnfang & ":G" & lngEnde))
End If
MsgBox dbSumme
End Sub
außerdem ist eine Fehlerbehandlung dabei, wenn die Uhrzeit garnicht auftritt.
Gruß
Chris