Sub SaveColumnToText(ByVal txtFile As String, _
ByRef arr As Variant, _
Optional ByVal UBRow As Long = -1)
Dim R As Long
Dim hFile As Long
Dim sStr as String
If UBRow = -1 Then
UBRow = UBound(arr)
End If
hFile = FreeFile
Open txtFile For Output As hFile
For R = 1 To UBRow - 1
Write #hFile, arr(R, 1)
Next
sStr = Trim(arr(UBRow, 1).Text)
If Not IsNumeric(sStr) Then _
sStr = Chr(34) & sStr & Chr(34)
Print #hFile, sStr;
Close #hFile
End Sub
You may have to add some more if statements/code to get sStr to behave the
same as Write would (for dates perhaps), but this doesn't put in the vbCrLf
--
Regards,
Tom Ogilvy
"RB Smissaert" wrote in message
...
I tried several different methods. This is one of them:
Sub SaveColumnToText(ByVal txtFile As String, _
ByRef arr As Variant, _
Optional ByVal UBRow As Long = -1)
Dim R As Long
Dim hFile As Long
If UBRow = -1 Then
UBRow = UBound(arr)
End If
hFile = FreeFile
Open txtFile For Output As hFile
For R = 1 To UBRow
Write #hFile, arr(R, 1)
Next
Close #hFile
End Sub
RBS
"Tom Ogilvy" wrote in message
...
Why not post the code, then we don't have to go from scratch. I assume
you
are not using SaveAs, but are using low level file IO.
If not look at:
http://support.microsoft.com/default...62&Product=xlw
Working with Sequential Access Files
--
Regards,
Tom Ogilvy
"RB Smissaert" wrote in message
...
I need to write a one-column range to a text file.
This text file has to be all the cells separated by linebreaks.
So it has to come out like this:
Cell1
Cell2
Cell3
etc.
The problem I have is that I can't avoid the text file ending with a
linebreak.
So in the above example when the cursor in the text file is after
Cell3,
you
can
still move one line further by pressing the down key.
This last linebreak is causing problems when the textfile will be
written
back to an array.
Thanks for any advice on this.
RBS