Public NFDeb
Sub Batch_OuvreTXT()
Close
'reprise ici
NFDeb = ActiveSheet.Name
'Stop
Cells(2, 1).Select
'Cells(,1).select:goto suite2
OuvreTXT
'Stop
For i = 2 To 13
'Open pathname For mode [Access access] [lock] As [#]filenumber [Len=reclength]
CHambre = Right(Cells(1, i).Value, 1)
Open ThisWorkbook.Path & "\" & "CH " & CHambre & "An2011.txt" For Output As #i
Print #i, "Date", vbTab, "CH" & CHambre
Next
'Stop
'copy les données du premier fichier vers chaque fichier capteur colonne 2 à 13
NLignes = Cells(65536, 1).End(xlUp).Row
For i = 2 To NLignes
For j = 2 To 13
Print #j, Cells(i, 1).Value, vbTab, Cells(i, j).Value
Next
Next
'Stop
ActiveWorkbook.Close 0
'suite2
'NLignes = Cells(, 1).End(xldown).Row
For Each cell In Range("a3:a" & Cells(65536, 1).End(xlUp).Row)
'For Each cell In Range("a" & ActiveCell.Row & ":a" & Cells(65536, 1).End(xlUp).Row)
cell.Select
OuvreTXT
If ActiveSheet.Name = NFDeb Then GoTo suite
NLignes = Cells(65536, 1).End(xlUp).Row
For i = 2 To NLignes
For j = 2 To 13
Print #j, Cells(i, 1).Value, vbTab, Cells(i, j).Value
Next
Next
'Stop
ActiveWorkbook.Close 0
suite:
Next
'Stop
Close
End Sub
Sub OuvreTXT()
'nao = "01 02 2011"
NAO = Cells(1, 2) & "\" & ActiveCell.Text
NAODate = Left(ActiveCell, 10)
Workbooks.OpenText Filename:=NAO, Origin:= _
xlMSDOS, StartRow:=1, DataType:=xlDelimited, TextQualifier:=xlDoubleQuote _
, ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False, Comma:= _
False, Space:=False, Other:=False, FieldInfo:=Array(Array(1, 1), Array(2, 1) _
, Array(3, 1), Array(4, 1), Array(5, 1), Array(6, 1), Array(7, 1), Array(8, 1), Array(9, 1), _
Array(10, 1), Array(11, 1), Array(12, 1), Array(13, 1), Array(14, 1)), DecimalSeparator _
:=".", TrailingMinusNumbers:=True
derl = Cells(65536, 1).End(xlUp).Row: If derl = 1 Then ActiveWorkbook.Close False: Exit Sub
For Each cell In Range("a2:a" & Cells(65536, 1).End(xlUp).Row)
'Stop
Valdate = Format(Left(NAODate, 2) & "/" & Mid(NAODate, 4, 2) & "/" & Right(NAODate, 4), "0")
ValHeure = Format(cell.Value, "0.000000000000000")
cell.Value = Val(Valdate) + CDbl(ValHeure)
Next
End Sub