title: Debugging #Value! on VBA
body: <p>When I run TEST() in the following VBA code, the result shows as belows
  <img src="https://i.stack.imgur.com/jop4N.png" alt="RESULT OF TEST()"></p>
  
  <p>But if I run LASTEST_DATE(..) in Excel Sheet, It shows #VALUE! error.</p>
  
  <p>Could you any one knows why?
  <img src="https://i.stack.imgur.com/tTG73.png" alt="RESULT IN EXCEL SHEET"></p>
  
  <pre><code>Public Function LASTEST_DATE(arg1 As String, arg2 As String) As Date
      Set aSheet = Worksheets("L4 CSU Schedule Excel Dump")
      Dim lastestDate As Date
  
      With aSheet.Range("A2:AA5000")
          Set System = .Find(What:=arg1, LookIn:=xlValues)
  
          If Not System Is Nothing Then
              firstAddress = System.Address
  
              Do
                  If (aSheet.Range("AA" &amp; System.Row) &gt; lastestDate) Then
                      lastestDate = aSheet.Range("AA" &amp; System.Row).Value
                  End If
  
                  Set System = .FindNext(System)
              Loop While Not System Is Nothing And System.Address &lt;&gt; firstAddress
          End If
  
      End With
  
      LASTEST_DATE = lastestDate
  End Function
  
  Public Sub TEST()
      Debug.Print (LASTEST_DATE(3100100, "System Commissioned"))
  End Sub
  </code></pre>