title: Efficiently transfer Excel formatting data to text file
body: <p>Here it is, I have a huge Excel workbook with which users write pricing quotes.  On save, rather than saving the huge workbook, I'm transferring the relevant data to a text file and saving that text file.  It's going off without a hitch, except for the one worksheet that contains formatting. I don't want the user to lose formatting when they load the previously saved quote (from the text file), so I need to determine a way to transfer that formatting data to and from the text file.  Is there a smart way to do this without writing hundreds of lines of code or using any non-native Excel feature?</p>
  
  <p>Here's a sample of the code for other sheets, but it's not much help for what I'm trying to do:</p>
  
  <pre><code>Sub WriteQuote()
  
  Dim SourceFile As String
  Dim data As String
  Dim ToFile As Integer
  Dim sh1, sh2, sh3 As Worksheet
  
  Set sh1 = Sheets("sheet 1")
  Set sh2 = Sheets("sheet 2")
  Set sh3 = Sheets("sheet 3")
  
  SourceFile = "C:\Users\███████\Desktop\test.txt"
  ToFile = FreeFile
  
  Open SourceFile For Output As #ToFile
  
  'PRINT DETAILS TO TXT FILE
  For i = 7 To 56
  If sh1.Range("B" &amp; i).Value &lt;&gt; "" Then
      data = sh1.Range("B" &amp; i).Value &amp; "__"
      If sh1.Range("D" &amp; i).Value &lt;&gt; "" Then
          data = data &amp; sh1.Range("D" &amp; i).Value &amp; "__"
      Else: data = data &amp; " __"
      End If
      If sh1.Range("E" &amp; i).Value &lt;&gt; "" Then
          data = data &amp; "ns" &amp; "__"
      Else: data = data &amp; " __"
      End If
      data = data &amp; sh1.Range("F" &amp; i).Value &amp; "__"
      data = data &amp; sh1.Range("G" &amp; i).Value &amp; "__"
      data = data &amp; sh1.Range("J" &amp; i).Value &amp; "__"
      data = data &amp; sh1.Range("M" &amp; i).Value
  Else: Exit For
  End If
  Print #ToFile, data
  Next i
  Close #ToFile
  End Sub
  </code></pre>