Reputation: 131
I'm using the VBA code below to export Excel rows to individual text file (file name is Column B)
Sub ExportTextFiles()
Dim i As Long
Dim LastDataRow As Long
Dim MyFile As String
Dim fnum
LastDataRow = ActiveSheet.Range("A" & Rows.Count).End(xlUp).Row
For i = 1 To LastDataRow
'The next line uses the contents of column B on the same row to name it
MyFile = "C:\test\" & ActiveSheet.Range("B" & i).Value & ".txt"
fnum = FreeFile()
Open MyFile For Output As fnum
Print #fnum, Format(Range("A" & i))
Close fnum
Next i
End Sub
My problem is only 255 Characters of row exported in the text. is there a workaround ?
Upvotes: 0
Views: 1480
Reputation: 60474
For reasons that I have not been able to find clear documentation, when you use the Format
function with no format defined, it will return only 255 characters.
I don't understand why you need to use the Format
function in your Print
statement, but if you remove it, the 255 character limitation seems to disappear.
The only thing I think you might have to worry about is the cell contents limitation of 32,767 characters.
Upvotes: 1