RobbieC
Active Member
- Joined
- Dec 14, 2016
- Messages
- 376
- Office Version
- 2010
- Platform
- Windows
Hi there, I have a series of sheets which I have been transposing the contents of to a text file. I have a series of subroutines which 'append' each sheet contents to make a master text file.
This has all been working fine, but I have just noticed that it has been failing to append certain sheets. This is the code which, so far, has been working fine:
The code basically takes the data in Sheets("DATA_FILE") and creates a comma seperated file 'DATA_TEMP.txt'
After looking at the data in the range for the failing modules, it seems that if some of the cells contain a large amount of text, it fails.
Is my code limiting the amount of characters in a string? If so, how can I get 'round this?
If you can point me in the right direction, I'd be most grateful. Thanks
This has all been working fine, but I have just noticed that it has been failing to append certain sheets. This is the code which, so far, has been working fine:
Code:
Sub ExportFILE()
Dim WS As Worksheet, txt As String, ff As Integer, i As Long
With Sheets("DATA_FILE").UsedRange
For i = 1 To .Rows.count
If .Columns.count = 1 Then
txt = txt & vbCrLf & Chr(34) & .Cells(1).Value & Chr(34)
Else
txt = txt & vbCrLf & Chr(34) & Join$(Application.Transpose _
(Application.Transpose(.Rows(i))), Chr(34) & "," & Chr(34)) & Chr(34)
End If
Next
End With
ff = FreeFile
Open ThisWorkbook.Path & "\DATA_Temp.txt" For Output As [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=ff]#ff[/URL]
Print [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=ff]#ff[/URL] , Mid$(txt, 3)
Close [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=ff]#ff[/URL]
txt = ""
End Sub
The code basically takes the data in Sheets("DATA_FILE") and creates a comma seperated file 'DATA_TEMP.txt'
After looking at the data in the range for the failing modules, it seems that if some of the cells contain a large amount of text, it fails.
Is my code limiting the amount of characters in a string? If so, how can I get 'round this?
If you can point me in the right direction, I'd be most grateful. Thanks