1

我正在使用 .find 搜索范围(“A20:AD20”)中的特定单元格,该单元格包含与变量 Lastdate 相同的日期,代码如下:

Set targetcell = ActiveSheet.Range("A20:AD20").Find(what:=Lastdate, LookIn:=xlValues, LookAt:=xlPart) //LookAt:=xlWhole does not work either

我调试时 Lastdate 的值是 6/1/2013,单元格 W20 的值也是 6/1/2013。我使用 MsgBox 并确认 Range("W20").value = Lastdate; 但是上面的代码找不到任何单元格。有人可以帮忙吗?十分感谢!

4

1 回答 1

0

Try forcing a real date:

Sub dural()
    Dim s As String
    s = "8/5/2013"
    Set zell = Cells.Find(What:=CDate(s), After:=Range("A1"), LookIn:=xlFormulas _
                , LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False)
    zell.Select
End Sub
于 2013-08-05T17:38:14.630 回答