title: Trying to convert iso 8601 datetime into real date time in excel vial vba
body: <p>I have found that how to convert this <code>2020-10-06T16:19:00</code> through Formula that is:</p>
  <pre><code>=DATEVALUE(MID(A1,1,10))+TIMEVALUE(MID(A1,12,8))
  </code></pre>
  <p>But i am trying to do this via VBA to apply it in whole column. Here is the <a href="https://stackoverflow.com/questions/4896116/parsing-an-iso8601-date-time-including-timezone-in-excel">VBA Examples</a></p>
  <p>and i tried this:</p>
  <pre><code>Public Function UTCToLocalTime(dteTime As Date) As Date
    Dim infile As FILETIME
    Dim outfile As FILETIME
    Dim insys As SYSTEMTIME
    Dim outsys As SYSTEMTIME
  
    insys.wYear = CInt(Year(dteTime))
    insys.wMonth = CInt(Month(dteTime))
    insys.wDay = CInt(Day(dteTime))
    insys.wHour = CInt(Hour(dteTime))
    insys.wMinute = CInt(Minute(dteTime))
    insys.wSecond = CInt(Second(dteTime))
  
    Call SystemTimeToFileTime(insys, infile)
    Call FileTimeToLocalFileTime(infile, outfile)
    Call FileTimeToSystemTime(outfile, outsys)
  
    UTCToLocalTime = CDate(outsys.wDay &amp; &quot;/&quot; &amp; _
      outsys.wMonth &amp; &quot;/&quot; &amp; _
      outsys.wYear &amp; &quot; &quot; &amp; _
      outsys.wHour &amp; &quot;:&quot; &amp; _
      outsys.wMinute &amp; &quot;:&quot; &amp; _
      outsys.wSecond)
    End Function
  </code></pre>
  <p>But receiving an error: Your help will be appreciated.</p>
  <p><a href="https://i.stack.imgur.com/uzAtw.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/uzAtw.png" alt="enter image description here" /></a></p>
  <pre><code>Sub ChangeFormat()
  
  Dim sh As Worksheet
  Dim Tuming As String
  Dim LastRow As Long
  
  Set ws = Sheet43
  LastRow = ws.Cells(Rows.Count, 1).End(xlUp).Row
  ws.Range(&quot;C2:C&quot; &amp; LastRow).NumberFormat = &quot;m/d/yyyy h:mm&quot;
  
  Tuming = &quot;2020-10-06T16:19:00&quot;
  
  Debug.Print UTCToLocalTime(Tuming)
  
  End Sub
  </code></pre>