title: How do I format the date in .find()?
body: <p>My VBA code below determines whether a given date is a working day or not. When it is not a working day, it will output the previous day's date.</p>
  
  <p>The problem is that it seems not to be respecting the date format. For example, when searching for 01/02/2015 it seemingly takes the date as 02/01/2015. Which causes a problem as 01/02/2015 may not be a working day, while 02/01/2015 could be.</p>
  
  <p>Here's the code:</p>
  
  <pre><code>Function FechaHabil(Fecha As Date, Rango As Range)
  
    'Rango is the set of non working dates
    'Fecha is the desired date to find
  
     Dim Flag As Integer
     Dim FechaFinal As Date
  
     FechaFinal = Format(Fecha, "dd/mm/yyyy")
     Flag = 0
     Do While Flag &lt;&gt; 1
       Set Busca = Rango.Find(FechaFinal, LookIn:=xlValues)
       If Not Busca Is Nothing Then
         FechaFinal = DateAdd("d", -1, FechaFinal)
         Flag = 0
       Else
         Flag = 1
       End If
     Loop
     FechaHabil = FechaFinal
  </code></pre>