Bonjour alors j'ai un macro excel qui importe le contenu d'un fichier texte dans une première feuille ensuite il cherche des termes pour les classer dans une deuxième feuille par suite les copier dans une troisième par ligne de données et ainsi de suite pour chaque ligne :
ce que je veux faire :
* Exécuter la macro chaque 5 secondes pour importer le texte dans ma 1ere feuille si il'y avait le mot "End Cycle" on continue l’exécution du macro si non on annule le tout et redémarrer après 5 secondes ainsi de suite ...
voila mon module :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
Option Explicit
Sub seleccionar1()
 
Dim cycle As String
Dim lot As String
Dim code As String
Dim start As String
Dim fin As String
Dim ph1 As String
Dim ph5 As String
Dim ph17 As String
Dim ph9 As String
Dim Alm As String
Dim r As Range
Dim tx As String
Dim uFila As Long
 
' apporter des données macro
'
 
   'Sheets.Add After:=ActiveSheet
   Workbooks.OpenText Filename:="C:\Users\DELL\Desktop\IT\ciclo.txt", _
        Origin:=xlWindows, StartRow:=1, DataType:=xlDelimited, TextQualifier:= _
        xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=False, Semicolon:=False _
        , Comma:=False, Space:=False, Other:=False, FieldInfo:=Array(1, 1), _
        TrailingMinusNumbers:=True
    Cells.Select
    Selection.Copy
    Windows("Repor_CH.xlsm").Activate
    Sheets("datos").Select
    Cells.Select
    ActiveSheet.Paste
 
 
    'Sheets("datos").Select
    cycle = "Cycle :"
    Columns(1).Find(cycle).Activate
    ActiveCell.Copy
    Sheets("Feuil1").Select
    Range("C1").Select
    ActiveSheet.Paste
 
 
    '  lot
 
    Sheets("datos").Select
    lot = "Lot  1"
    Columns(1).Find(lot).Activate
    ActiveCell.Copy
    Sheets("Feuil1").Select
    Range("C2").Select
    ActiveSheet.Paste
 
    '  produit
 
    Sheets("datos").Select
    code = "Code 1"
    Columns(1).Find(code).Activate
     ActiveCell.Copy
     Sheets("Feuil1").Select
    Range("C3").Select
    ActiveSheet.Paste
 
    '  heure de début
 
    Sheets("datos").Select
    start = "START"
    Columns(1).Find(start).Activate
     ActiveCell.Copy
     Sheets("Feuil1").Select
    Range("C4").Select
    ActiveSheet.Paste
 
    '  heure final
 
    Sheets("datos").Select
    fin = "END CYCLE"
    Columns(1).Find(fin).Activate
    ActiveCell.Copy
    Sheets("Feuil1").Select
    Range("C5").Select
    ActiveSheet.Paste
 
    '  charger de l'eau
 
    Sheets("datos").Select
    ph1 = "PLC Duration Phase    [33]"
    Columns(1).Find(ph1).Activate
     ActiveCell.Copy
     Sheets("Feuil1").Select
    Range("C6").Select
    ActiveSheet.Paste
 
    '  chauffage
 
    Sheets("datos").Select
    ph5 = "PLC Duration Phase    [5]"
    Columns(1).Find(ph5).Activate
     ActiveCell.Copy
     Sheets("Feuil1").Select
    Range("C7").Select
    ActiveSheet.Paste
 
    '  Stérilisation
 
    Sheets("datos").Select
    ph17 = "PLC Duration Phase    [17]"
    Columns(1).Find(ph17).Activate
     ActiveCell.Copy
     Sheets("Feuil1").Select
    Range("C8").Select
    ActiveSheet.Paste
 
    '  refroidissement
 
    Sheets("datos").Select
    ph9 = "PLC Duration Phase    [9]"
    Columns(1).Find(ph9).Activate
     ActiveCell.Copy
     Sheets("Feuil1").Select
    Range("C9").Select
    ActiveSheet.Paste
 
    '  temps fin stérilisation
 
    Sheets("datos").Select
    ph17 = "PLC Duration Phase    [17]"
    Columns(1).Find(ph17).Activate
    ActiveCell.Offset(-3, 0).Select
    Selection.Copy
    Sheets("Feuil1").Select
    Range("C11").Select
 
    ActiveSheet.Paste
    Sheets("datos").Select
    ActiveCell.Offset(1, 0).Select
    Selection.Copy
    Sheets("Feuil1").Select
    Range("C12").Select
    ActiveSheet.Paste
 
    Sheets("Feuil1").Select
 
    Sheets("datos").Select
 
  uFila = ActiveSheet.Cells(Rows.Count, ActiveCell.Column).End(xlUp).Row
 
  tx = "Alarms occurred during cycle"
 
  If tx <> "" Then
    For Each r In Range(ActiveCell.Address, Cells(uFila, ActiveCell.Column))
      If InStr(1, ActiveCell.Value, tx) > 0 Then
        Alm = "YES"
      End If
      Selection.Offset(1).Select
    Next r
    Sheets("Feuil1").Select
    Range("B19").Select
    ActiveCell = Alm
 
 
  End If
 
 
 
    ' supprimer la feuille
 
 
 
    Sheets("datos").Select
    Columns("A:A").Select
    Selection.Delete Shift:=xlToLeft
    Range("F14").Select
    Sheets("Feuil1").Select
 
    ' points dans le rapport
 
     Rows("19:19").Select
    Selection.Copy
    Sheets("report").Select
    Rows("4:4").Select
    Selection.Insert Shift:=xlDown
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Sheets("Feuil1").Select
    Range("E37").Select
 
    Sheets("report").Select
 
 
   ' fermer le fichier de cycle importé
 
   Windows("ciclo.txt").Activate
    ActiveWorkbook.Close
 
 
End Sub