• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Extract excel data to notepad but extra line/space

Shiroi14

New Member
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 <<<
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:
71491
 

Attachments

  • VBA Macro.xlsx
    7.8 KB · Views: 3
  • MM_M01_Material master-分类数据-半成品 (17Aug).xlsx
    65.4 KB · Views: 2
  • M060 (H).txt
    5.2 KB · Views: 1
Last edited by a moderator:
Shiroi14
Hint: You have uploaded partial code and .xlsx-file which do not have any code.
There seems to be four 'empty columns' in the end of every line too.
Do You have a plan to use that text-file as a text-file?
 
Back
Top