title: write a basic formula in VBA code for Excel (string date text to date format)
body: <p>Our accounting software exports dates as 07262013 as text.  To convert this string of text to date format, I normally type the formula </p>
  
  <pre><code>=IF(A2&gt;10000000,DATE(VALUE(RIGHT(A2,4)),VALUE(LEFT(A2,2)),VALUE(MID(A2,3,2))),
  DATE(VALUE(RIGHT(A2,4)),VALUE(LEFT(A2,1)),VALUE(MID(A2,2,2)))) 
  </code></pre>
  
  <p>each time I export data.  I want to write a custom function as <code>=convert_text(text)</code> to complete the same function.</p>
  
  <p>I came up with</p>
  
  <pre><code>Function Convert_Date(text)
   If text &gt; 10000000 Then
      Convert_Date = Application.Date(Application.Value(Application.Right(text, 4)), Application.Value(Application.Left(text, 2)), Application.Value(Application.Mid(text, 3, 2)))
   Else
      Convert_Date = Application.Date(Application.Value(Application.Right(text, 4)), Application.Value(Application.Left(text, 1)), Application.Value(Application.Mid(text, 2, 2)))
  End Function
  </code></pre>
  
  <p>Thank you so much in advance!
  Lee</p>