为什么我的VBA找不到任何东西?

我有我认为是一个非常简单的。find,但它不工作。

 lngLastRow = wsFound.Range("D" & Rows.count).End(xlUp).Row Set SearchRange = wsFound.Range("D1:D" & lngLastRow) For Each a In wsFound.Range(wsFound.Range("D2"), wsFound.Range("D" & Rows.count).End(xlUp)) With SearchRange Set c = .Find("01/03/1950", LookIn:=xlValues) 'a.Value, LookIn:=xlValues) If Not c Is Nothing Then Firstfind = a.Address Do wsFound.Range("A" & a.Row & ":U" & a.Row).Copy LastRow = ActiveWorkbook.Sheets("Duplicates").Range("A" & Rows.count).End(xlUp).Row + 1 ActiveWorkbook.Sheets("Duplicates").Range("A" & LastRow).PasteSpecial Set c = .FindNext(c) If c Is Nothing Then GoTo DoneFinding End If Loop While a.Address <> Firstfind End If 

DoneFinding:以下结束a

我很确定,我已经得到了这个正确的,我使用从MSDN的信息得到这一点。

但它没有find任何东西!

我的数据如下所示:

 +--------------+---------+-----------+---------------+--------------+ | A | B | C | D | E | +--------------+---------+-----------+---------------+--------------+ | Staff Number | Surname | Forenames | Date of Birth | Address 1 | +--------------+---------+-----------+---------------+--------------+ | 1000064036 | Farrell | Margaret | 01/03/1950 | 11 The Close | | 1000064036 | Farrell | Margaret | 01/03/1950 | 11 The Close | | 1000064036 | Farrell | Margaret | 01/03/1950 | 11 The Close | +--------------+---------+-----------+---------------+--------------+ 

所以我知道应该findDOB D列中有3个重复项。

我终于find了一些更多的search,根据David Zemens的评论,我的search更具体。

这是什么工作:

 For Each a In wsFound.Range(wsFound.Range("D2"), wsFound.Range("D" & Rows.count).End(xlUp)) With SearchRange Set c = SearchRange.Find(a.Value, LookIn:=xlFormulas, LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext) If Not c Is Nothing Then Firstfind = a.Address Do wsFound.Range("A" & a.Row & ":U" & a.Row).Copy LastRow = ActiveWorkbook.Sheets("Duplicates").Range("A" & Rows.count).End(xlUp).Row + 1 ActiveWorkbook.Sheets("Duplicates").Range("A" & LastRow).PasteSpecial Set c = .FindNext(c) If c Is Nothing Then GoTo DoneFinding End If Loop While a.Address <> Firstfind End If DoneFinding: End With Next a 

我不得不将LookInxlValuesxlformulas ,现在即使不使用CDate ,也可以find我正在查找的date。

我从另外一个问题的评论中发现了这一点。 在列VBA中查找date值 ,评论由Eric K