title: Export Excel range to TXT stop at empty cell
body: <p>Found following script</p>
  
  <pre><code>Sub saveText2()
  Dim filename As String, lineText As String
  Dim myrng As Range, i, j
  
  filename = ThisWorkbook.Path &amp; "\textfile-" &amp; Format(Now, "ddmmyy-hhmmss") &amp; ".txt"
  
  Open filename For Output As #1
  
  Set myrng = Range("Name")
  
  For i = 1 To myrng.Rows.Count
      For j = 1 To myrng.Columns.Count
          lineText = IIf(j = 1, "", lineText &amp; ",") &amp; myrng.Cells(i, j)
      Next j
      Print #1, lineText
  Next i
  Close #1
  End Sub
  </code></pre>
  
  <p>But I don´t seems to manage to stop the loop at first empty row.</p>
  
  <p>I´ve tried to add a DO While myrng &lt;> "" Loop but I don´t know where to apply the code.  </p>