Sub Macro1()
Dim cell As Range
Dim MyDay As Integer, MyYear As Integer, MyMonth As Integer
Dim MyDate As Date
MyDate = Format(MyYear & "/" & MyMonth & "/" & MyDay, "dd/mm/yyyy") < --Error
Selection.Formula = ""
Range("M1").Select
Sheets("Case Settled in 2012").Select
Cells.Find(What:=MyDate, After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Activate
MsgBox MyDay
End Sub
我想搜索数据date=today
答案 0 :(得分:3)
MyDate =格式(MyYear&amp;“/”&amp; MyMonth&amp;“/”&amp; MyDay,“dd / mm / yyyy”)&lt; - 错误
您需要的是DateSerial
MyDate = DateSerial(MyYear, MyMonth, MyDay)
您还需要初始化这些变量。
修改强>
我想搜索数据date = today
关于你的第二个问题,@ Mehow已经向你展示了如何遍历一个范围来在你的其他question中进行日期比较。在这里做一个类似的比较,并检查日期是否匹配。