data on my Excel sheet Я хотел бы найти дату в столбце A. Это форма даты: "yyyy/mm/dd hh: mm: ss". Он всегда не найти ничего, но дата, что я ищу в колонке А. Это фрагмент моего кода:Найти значение даты в столбце 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: Новый код в комментарии.
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
Из кода вы предоставляете, не кажется, что вы какое-либо значение для вашего 'LastDay' переменной. – Carrosive
Код u написал базу поиска на xlValue. Хранилище данных в ячейках фактически является просто номером. Поэтому вы не сможете найти его с помощью LookIn: = xlValue –
Также может быть, что формат (конвертирует дату в строковый формат, и вы ищете дату – User632716