Search code examples
stringexceltextworksheet-functionvba

Insert characters into string in different locations


I have a string which looks like this 20141007023617. And I would like to make it look like this 2014-10-07T02:36:17Z. The T and Z are very important for me. So I would like to insert them as well.

So a recap,

A1 holds this string 20141007023617

B1 should hold this string 2014-10-07T02:36:17Z


Solution

  • Please try, Record Macro and:

    =LEFT(A1,4)&"-"&MID(A1,5,2)&"-"&MID(A1,7,2)&"T"&MID(A1,9,2)&":"&MID(A1,11,2)&":"&MID(A1,13,2)&"Z"