View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.setup
Piotr Krasnicki
 
Posts: n/a
Default Problem with exporting xls sheels to txt files separated by ta

Thank you very much for your help. That was exactly what I wanted to achieve.
For those who might have the same problem I had I am enclosing whole macro
that fixs the issue (I found it somewhere on one of tutorial pages). To use
it you just select those fields you want to export and then run that macro.
File is saved under c:\MyOutput.txt

Sub Export()
Dim r As Range, c As Range
Dim sTemp As String
Open "c:\MyOutput.txt" For Output As #1
For Each r In Selection.Rows
sTemp = ""
For Each c In r.Cells
sTemp = sTemp & c.Text & Chr(9)
Next c
'Get rid of trailing tabs
While Right(sTemp, 1) = Chr(9)
sTemp = Left(sTemp, Len(sTemp) - 1)
Wend
Print #1, sTemp
Next r
Close #1
End Sub


Best regards,
Piotr