在VBA中使用WorksheetfFnction.match时出错

我有一个简单的问题,我无法解决。 在我的excel工作簿中,AI中有一组date。 从这组date我想find一个特定的date(最近的date),并报告date的行号。 我可以设法finddate,但不是行号。 我到目前为止所做的是:

Option Base 1 Option Explicit Sub Macro() Dim maxdate As Date Dim k As Integer Dim row As Integer maxdate = WorksheetFunction.Max(Range("A:A")) If maxdate < VBA.Date And maxdate > 0 Then row = Application.WorksheetFunction.Match(maxdate, Range("A:A"), 0) k = row End If If maxdate = 0 Then k = 0 End If End Sub 

当执行包含“row = Application.WorksheetFunction.Match()”的代码行时,VBA报告错误:运行时错误“1004”:无法获取工作表函数类的匹配属性。

但是,报告了正确的最大date。 我很欣赏任何input?

BR,Jesper

MATCH()不喜欢VBA date。 ………………..所以:

 Option Base 1 Option Explicit Sub Macro() Dim maxdate As Date Dim k As Long Dim row As Long maxdate = WorksheetFunction.Max(Range("A:A")) If maxdate < VBA.Date And maxdate > 0 Then row = Application.WorksheetFunction.Match(CLng(maxdate), Range("A:A"), 0) If Not IsError(row) Then k = row Else: MsgBox maxdate & " not found!" End If End If If maxdate = 0 Then k = 0 End If MsgBox k End Sub