title: select range & copy/paste to notepad - Almost done
body: <p>After a lot of work and testing (very pathetic indeed), I finally managed to select a range in <em>worksheets</em>, then copy/paste it in Notepad. The file shall be thereafter readen by another app. Unfortunately, the app reject the file and there is no way for me to debug why. The only message I have is an error occuring at <em>last line</em>.</p>
  
  <p>Surprisingly, when I copy-paste to notepad by hand, it works. As far as my eyes can see, both txt files (the one writen with my <em>sub()</em> and the one from CP by hand) are exactly the same. I guess my eyes are wrong. I suspect there is at the end of last line or below last row maybe some <strong><em>white space</em></strong> I can not see. The only part of code I do not fully understand is, according to me, the place of the current issue.</p>
  
  <p>Find below part of my code:</p>
  
  <pre><code>[code]
  ' RngSelect is a Variant and effectively a range of cells 
  ' Txt is a Variant
  ' LastRow is a Long equal to last row number of my range
  
  With RngSelect
  For Lg1 = 1 To LastRow
      Txt = Txt &amp; vbCrLf &amp; Join$(Application.Transpose(Application.Transpose(.Rows(Lg1).Value)),vbTab)   ' copy each row    
  Next
  End With
  
  Open FilePath For Output As #1
  Print #1, Mid$(Txt, Len(vbCrLf) + 1)
  Close #1
  
  RngSelect = Null
  Txt = Null
  
  End Sub
  </code></pre>
  
  <p>If it can help, my file to be imported by the other app can be in a csv format. Currently, my delimiter is <strong>Tab</strong>.</p>
  
  <p>Thank you for help.</p>