title: VBA - setting a date format to a variable
body: <p>Novice <code>VBA</code> user here. I think this might be a very easy question to answer, but I cant find the solution on here on any other site so apologies if that's the case.</p>
  
  <p>I am writing a very short piece of code that inserts the latest business day into a column where its not already present and moves onto the next column and runs the same process where it is present. The code is below. Note I have simplified this by but removing the else condition. I want to set the date format for the <code>lastbusinessday</code> variable to be <code>"dd/mm/yyyy"</code> - at the moment its including <code>hh/mm/ss</code> which is causing the if function to not work properly.</p>
  
  <p>How can i declare the conditions for this variable?</p>
  
  <pre><code>Sub Dateextend4()
      Dim lastbusinessday As Date
  
      If Weekday(Now()) = 2 Then
          lastbusinessday = (Now() - 3)
      Else
          lastbusinessday = (Now() - 1)
      End If
  
      Sheets("pb CDS").Select
      Range("b13").Select
      Selection.End(xlDown).Select
  
      If ActiveCell.Offset(0, 0).Value &lt; lastbusinessday Then
          ActiveCell.Offset(1, 0) = format(lastbusinessday, "mm / dd / yyyy")
      Else
      End If
  End Sub
  </code></pre>
  
  <p>Thanks</p>