1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
| Sub OuvreFichL3()
Dim B$(), bb$(4), Item As Object
Dim i As Byte, LastLg As Long
Dim Name As String
Dim NC As Boolean
Dim tabNC()
Dim Ligne As Long
Dim Start, EndStart
Start = Timer
Application.ScreenUpdating = False
Application.EnableEvents = False
Application.Calculation = xlCalculationManual
'On Error Resume Next
reponse = Application.GetOpenFilename _
("All Files (*.*),*.*")
If reponse = False Then Exit Sub
Canal = FreeFile
Open reponse For Input As #Canal
[A1].Value = "Numéro"
Range("A2:A" & [A65000].End(xlUp).Row + 1).ClearContents
Range("A2:A" & [A65000].End(xlUp).Row + 1).Interior.Pattern = xlNone
Do While Not EOF(Canal)
Line Input #Canal, a$
If Len(Trim(a$)) > 0 Then '-- Si la ligne est non vide
If InStr(1, a$, "ABN") > 0 Then
'-- Lire une nouvelle ligne
Line Input #Canal, a$
' Si la ligne contient la chaine WO en passe
If InStr(1, a$, " WO") > 1 Then
Line Input #Canal, a$
Continue = True
Else
Continue = True
End If
Do While Continue
Debug.Print a$
B$ = Split(Trim(a$), " ")
i = 0: j = 0
' On parcours le tableau résultant
For Each Item In B$
' Si l'élément du tableau est non vide
If Len(Trim(Item)) > 0 Then
If InStr(1, Item, "L3-") > 0 And _
InStr(1, Item, "&") = 0 Then
'Debug.Print Item
' Si la ligne suivante contient la chaine CL
' on ne comptabilise pas la l'élément en cours
Line Input #Canal, a$ 'ICI on devra relire cette ligne si elle ne contient pas de CL ???
If InStr(1, a$, "CL") = 0 Then
li = Split(Item, "-")
'-- Ecriture dans le feuille
LastLg = [A65000].End(xlUp).Row + 1
Cells(LastLg, 1) = li(1)
Rem.
'-- Ecriture dans un tableau
'---
Rem.
'Colorier en jaune les lignes contenants CN
If InStr(1, a$, "CN") > 0 Then
Cells(LastLg, 1).Interior.ColorIndex = 6
End If
i = i + 1
End If
End If
End If
j = j + 1
Next Item
End If
' Lecture d'une nouvelle ligne
Line Input #Canal, a$
If InStr(1, a$, "WO") > 1 Then
Line Input #Canal, a$
ElseIf InStr(1, a$, "END") > 1 Then
Continue = False
End If
Loop
End If
End If
Loop
Close #Canal
Range("A1:A65000").Sort Key1:=Range("A1"), Order1:=xlAscending, Header:=xlGuess
MsgBox "Sort complete.", vbInformation
'On Error GoTo 0
Application.ScreenUpdating = True
Application.EnableEvents = True
Application.Calculation = xlCalculationAutomatic
[B10] = Timer - Start
MsgBox "Temp d'exécution" & [B10]
End Sub |
Partager