data on my Excel sheet Ich mag würde ein Datum in Spalte A finde Dies ist das Datum Format: "yyyy/mm/dd hh: mm: ss". Es hat nichts immer zu finden, aber das Datum, was ich für ist in der Spalte A. bin auf der Suche Dies ist ein Ausschnitt aus meinem Code:Suche Datum Wert in einer Spalte VBA
Dim LastDay As Date
Dim strdate As String
Dim rCell As Range
strdate = Format(LastDay, "yyyy/mm/dd hh:mm:ss")
Set rCell = Cells.Find(What:=CDate(strdate), After:=Range("A1"), LookIn:=xlValues _
, LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False)
If rCell Is Nothing Then
MsgBox ("nothing")
Else
EDIT: Neuer Code pro Kommentar.
Sub Copy()
Dim LastDayRow As Long
Dim FirstDayRow As Long
Dim LastDay As Date
Dim FirstDay As Date
Dim rcell As Range
LastDayRow = Range("E" & Rows.Count).End(xlUp).Row
Range("E" & LastDayRow).Copy Range("G1")
FirstDayRow = Range("A" & Rows.Count).End(xlUp).Row
Range("A" & FirstDayRow).Copy Range("G2")
LastDay = Cells(LastDayRow, "E").Value
FirstDay = Cells(FirstDayRow, "A").Value
Set rcell = Cells.Find(What:=LastDay, After:=Range("A1"), LookIn:=xlFormulas _
, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext)
If rcell Is Nothing Then
MsgBox ("nothing")
End If
End Sub
Aus dem Code, den Sie zur Verfügung stellen, es scheint nicht, dass Sie einen beliebigen Wert zu 'LastDay' Variable gesetzt. – Carrosive
Der Code, den Sie schreiben, ist die Basis von xlValue. Der Datumsspeicher in Zellen ist eigentlich nur die Nummer. Daher können Sie es mit LookIn nicht finden: = xlValue –
Es könnte auch sein, dass das Format (konvertiert das Datum in ein String-Format; und Sie suchen nach einem Datum – User632716