Hallo Trägheit
vielen Dank! Dein Code Funktioniert wunderbar!
Jetzt würde ich aber gerne noch einen Schritt weitergehen und eine Date suchen, dass aus einem Datum und einer Zeit besteht. Ich habe zwar eine Methode (im Code unten 'Methode2'), die funktioniert, aber Deinen Ansatz (im Code unten 'Methode1') kann ich nicht übertragen. Z.B.
Spalte A Spalte B Spalte C
01.07.2014 11:30:00 = A + B
01.07.2014 12:30:00 = A + B
01.07.2014 14:30:00 = A + B
02.07.2014 14:30:00 = A + B
03.07.2014 14:30:00 = A + B
Sub finde_time()
Dim rngStart As Excel.Range
Dim time_Start As Date
Dim date_start As Date
Dim date_time_start As Date
'Input Example
time_Start = TimeSerial(14, 30, 0)
date_start = DateSerial(2014, 7, 2)
date_time_start = date_start + time_Start
Debug.Print date_time_start
'Suchemethode 1
With Range("C:C")
Set rngStart = .Find(date_time_start, LookIn:=xlFormulas, LookAt:=xlWhole)
End With
If rngStart Is Nothing Then
Debug.Print "start time: <not found>"
Else: Debug.Print "start time: ", rngStart.Address
End If
'Suchmethode 2
Dim date_time_start_Double As Double
Dim Row_Start_Date_Time As Double
date_time_start_Double = date_start + time_Start
Range("C:C").NumberFormat = "0.0000000000"
Row_Start_Date_Time = WorksheetFunction.Match(date_time_start_Double, Range("C:C"), 0)
Debug.Print "start time is in row: ", Row_Start_Date_Time
End Sub
|