same code but not working with all txt file

Status
Not open for further replies.

SBAY3I

Board Regular
Joined
Jul 21, 2018
Messages
53
hi
i have 3 différents txt files, the code working on two file but the tirth one not working , any suggestions in this case

VBA Code:
Sub lirebenzing(nf)
    With Sheets("résultats")
        k = .Cells(Rows.Count, 1).End(xlUp).Row
        Open nf For Input As 1
        Do
            Line Input #1, v
            If v <> "" Then
                q = Mid(v, 3, 7)
                If q = "BENZING" Then
                    q = Mid(v, 57, 19)
                    de$ = Trim(Replace(Replace(Replace(q, ".", "/"), "-", " "), "|", ""))
                    nr = 0
                    sr = 0
                Else
                    q = Left(v, 7)
                    If q = "Amateur" Then
                        propn = Mid(v, 56)
                        propn = Trim(propn)
                        propid = Mid(v, 17, 12)
                        xp = 0
                        yp = 0
                        setxyp propn, propid, xp, yp
                    Else
                        s = InStr(v, "Lieu de lacher")
                        If s <> 0 Then
                            s1 = InStr(v, ":")
                            lieuid = Mid(v, s1 + 1, s - s1 - 2)
                            lieun = Mid(v, s + 15)
                            lieun = Trim(lieun)
                        ElseIf lieuid <> "" And (Left(v, 3) = "No." Or Left(v, 3) = "Ord") Then
                            nr = 1
                        ElseIf Left(v, 3) = "---" Or Left(v, 3) = "+--" Then
                            If nr = 1 Then sr = 1
                        ElseIf Left(v, 3) = "+--" Or InStr(v, "Signatur") <> 0 Then
                            nr = 0
                            sr = 0
                        ElseIf sr = 1 Then
                            If Not dp Then
                                k = k + 1
                                .Cells(k, 1) = course
                                .Cells(k, 2) = datecourse
                                .Cells(k, 3) = "'" & propid
                                .Cells(k, 4) = propn
                                t = Split(v, "|")
                                .Cells(k, 5) = t(0)
                                .Cells(k, 5) = Val(.Cells(k, 5))
                                .Cells(k, 6) = "'" & t(6)
                                t1 = Split(suppresp(t(1)), " ")
                                .Cells(k, 7) = "'" & t1(1)
                                .Cells(k, 8) = "'" & t1(2)
                                .Cells(k, 9) = "'" & t1(3)
                                j = 4
                                While t1(j) = ""
                                    j = j + 1
                                Wend
                                .Cells(k, 10) = "'" & t1(j)
                                .Cells(k, 11) = "'" & t(2)
                                .Cells(k, 12) = "'" & t(3)
                                If Left(t(4), 6) <> "pas ar" Then
                                    .Cells(k, 13) = "'" & Left(t(4), 3)
                                    .Cells(k, 14) = TimeValue(Mid(t(4), 6))
                                End If
                                .Cells(k, 16) = idcourse
                                .Cells(k, 17) = de
                                .Cells(k, 18) = "BENZING"
                                .Cells(k, 19) = nf
                                .Cells(k, 20) = x
                                .Cells(k, 21) = y
                                .Cells(k, 22) = xp
                                .Cells(k, 23) = yp
                                .Cells(k, 24) = Sqr((xp - x) ^ 2 + (yp - y) ^ 2)
                                If Val(.Cells(k, 5)) <> 0 Then
                                    .Cells(k, 25) = .Cells(k, 14) - (datecourse - Int(datecourse))
                                    .Cells(k, 26) = .Cells(k, 24) * 1000 / (.Cells(k, 25) * 24 * 60)
                                End If
                            End If
                        End If
                    End If
                End If
            End If
        Loop While Not EOF(1)
        Close
    End With
End Sub
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Cross-posting (posting the same question in more than one forum) is not against our rules, but the method of doing so is covered by #13 of the Forum Rules.

Be sure to follow & read the link at the end of the rule too!

Cross posted at: macro reading txt file but not with other

As this is at least the third warning about cross-posting without links, your account has been banned for a week. Any further breaches of this or other rules will result in a permanent ban.
 
Upvote 0
Duplicate to: macro not working with all txt files

In future, please do not post the same question multiple times. Per Forum Rules (#12), posts of a duplicate nature will be locked or deleted.

In relation to your question here, I have closed this thread so please continue in the linked thread.
 
Upvote 0
Status
Not open for further replies.

Forum statistics

Threads
1,224,824
Messages
6,181,186
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top