title: Macro code in Excel VBA isn't running as expected
body: <p>I'm trying to write a macro where EXCEL does the following : </p>
  
  <ul>
  <li>Changes the data in A1 , B1, C1, etc... to a specific date format (dd-mm-yyyy)</li>
  <li>Uses the DATEDIFF function to calculate the days between the values in A1 and B1 and between A1 and C1 </li>
  <li>Puts the results of that DateDIFF function in another cell</li>
  </ul>
  
  <p>I keep getting stranges values and reset of my function</p>
  
  <p>This is the code i'm using now but i keep getting errors : </p>
  
  <pre><code>Private Sub CommandButton1_Click()
  Range("A1:A5000").NumberFormat = "dd-mm-yyyy"
  Range("B1:B5000").NumberFormat = "dd-mm-yyyy"
  End Sub
  
  Private Sub CommandButton2_Click()
  
  Dim n As Variant
  Dim Range("A1:A5000") As Date
  Dim Range("B1:B5000") As Date
  
  n = DateDiff("d", Range("A1:A5000"), Range("B1:B5000"))
  n = Range("C1:C5000")
  
  End Sub
  </code></pre>
  
  <p>UPDATE : </p>
  
  <p>The error in VBA = TYPE MISMATCH.</p>
  
  <p>A little more explanation for this : </p>
  
  <ol>
  <li>User copies dates in to the first 3 colums (A, B, C)</li>
  <li>My Macro (script) has to change these values into a standard format (dd-mm-yyyy)</li>
  <li><p>Another Button or script has to calculate the days between : 
  A and B 
  B and C
  A and C</p></li>
  <li><p>The days calculated by 3 had to be put in another column (H or something) so it can be reported.</p></li>
  </ol>
  
  <p>I'm sorry if i was not that clear, it's my first time using Stackoverflow.</p>
  
  <p>Regards,</p>