I have a macro that is used to export data to a ~ delimited file. The macro runs fine with Excel 2003. However when we try to use it in an excel 2007 file it takes forever to export the data. I.E. in excel 2003, I can export 65k rows of data in just 6 minutes. However it took 53 minutes to export 45k rows in excel 2007. I would appreciate any help with solving this issue. The macro code is below:
Sub Export_Local_TP_Source()
'Delete existing tp_source.txtx file
On Error Resume Next
Kill "c:\temp\TP_source.txt"
On Error GoTo 0
'
'Start of actual export
'Public Sub CharacterSV()
Const DELIMITER As String = "~"
Dim myRecord As Range
Dim myField As Range
Dim sOut As String
Open "c:\temp\TP_source.txt" For Output As #1
For Each myRecord In Range("A2:A" & _
Range("A" & Rows.Count).End(xlUp).Row)
With myRecord
For Each myField In Range(.Cells, _
Cells(.Row, Columns.Count).End(xlToLeft))
sOut = sOut & DELIMITER & myField.Text
Next myField
Print #1, Mid(sOut, 2)
sOut = Empty
End With
Next myRecord
Close #1
'End Sub
'end of export
MsgBox "File exported to: c:\temp\TP_source.txt", vbOKOnly
End Sub
Bookmarks