title: Error type mismatch - How do I create a .txt file from all of the data in column A sheet 1
body: <p>I keep getting the type mismatch error on this line of code.</p>
  
  <pre><code>stream.WriteLine CellData
  </code></pre>
  
  <p>Full code below</p>
  
  <pre><code>Sub Write_to_File()
  
  Dim FilePath As String
  Dim CellData As Variant
  Dim LastCol As Long
  Dim LastRow As Long
  
  
  Dim fso As FileSystemObject
  Set fso = New FileSystemObject
  Dim stream As TextStream
  
  
  
  
  ' Create a TextStream.
  Set stream = fso.OpenTextFile("C:\...\test_labs.txt", ForWriting, True)
  
  var3 = Worksheets("label").Columns(1)
  
  CellData = ""
  
       CellData = var3
       stream.WriteLine CellData
  
  stream.Close
  MsgBox ("Done")
  
  End Sub
  </code></pre>
  
  <p>I am trying to get all of column A in sheet 1 to write to the text file. This code is run from a command button in sheet 2. I'm still new to VBA so any help is appreciated.</p>
  
  <p>Thanks</p>