Dear Friends,
I am trying to copy an Excel range to a M060 (H).txt file.
Export successful, with one exception, It adds one "extra" empty line/space at the end.
I've read and tests many of the solution on SO (and other sites), but still without any success.
All i want is to remove extra spaces/line which is coming at the end.
Here my code:
>>> use code - tags <<<
Output txt:
I am trying to copy an Excel range to a M060 (H).txt file.
Export successful, with one exception, It adds one "extra" empty line/space at the end.
I've read and tests many of the solution on SO (and other sites), but still without any success.
All i want is to remove extra spaces/line which is coming at the end.
Here my code:
>>> use code - tags <<<
Code:
''''''''''''''''''''''''''''''''''''''''''Create M060 (H)''''''''''''''''''''''''''''''''''''''''''''''''''
mfile = OpenFile(2, Frompath)
Set wbH = Workbooks.Open(Frompath & mfile, UpdateLinks:=False)
wbH.Activate
Dim myFileName1 As String
Dim H60rng As Range
Dim H60all As String
Dim p1, q1
myFileName1 = "M060 (H)"
myFileName1 = myFileName1 & ".txt"
myFileName1 = sPathH & myFileName1
H1 = FreeFile
Open myFileName1 For Output As #H1
lastrow3 = Range("A" & Rows.Count).End(xlUp).Row
Set H60rng = Range("A8:N8")
For p1 = 8 To lastrow3
For q1 = 1 To H60rng.Columns.Count
H60all = IIf(q1 = 1, "", H60all & Chr(9)) & H60rng.Cells(p1 - 2, q1)
Next q1
Print #H1, H60all
If p1 > 2 And Cells(p1, 3).Value <> Cells(p1 + 1, 3) Then
H60all = ""
Print #H1, H60all
Else
'Do Nothing
End If
Next p1
Close #H1
ActiveWorkbook.Close SaveChanges:=False
Output txt:
Attachments
Last edited by a moderator: