Option Explicit
Type ficheNom
ope As String * 4
num As String * 13
ident As String * 34
dat As String * 15
P01 As String * 6
P02 As String * 12
pointage1 As String * 8
pointage2 As String * 8
pointage3 As String * 8
pointage4 As String * 8
pointage5 As String * 8
pointage6 As String * 8
fin As String * 24
cr As String * 2
End Type
Sub texte()
Dim datas
Dim numfich As Integer, lig As Long, col As Long
Dim fiche As ficheNom
With Sheets("DATA")
datas = .[A2:L2].Resize(.Cells(.Rows.Count, 1).End(xlUp).Row - 1).Value
End With
numfich = FreeFile
Open "D:\tmp\test.txt" For Random As #numfich Len = Len(fiche)
For lig = 1 To UBound(datas)
fiche.ope = "1 |"
fiche.num = Format(datas(lig, 1), "00000")
fiche.ident = datas(lig, 3) & "," & datas(lig, 2)
fiche.dat = Format(datas(lig, 4), "dd/mm/yyyy")
fiche.P01 = Format(datas(lig, 5) / 1440, "hh:mm")
fiche.P02 = "-" & Format(datas(lig, 6) / 1440, "hh:mm")
fiche.pointage1 = IIf(datas(lig, 7) = 0, "", Format(datas(lig, 7) / 1440, "hh:mm"))
fiche.pointage2 = IIf(datas(lig, 8) = 0, "", Format(datas(lig, 8) / 1440, "hh:mm"))
fiche.pointage3 = IIf(datas(lig, 9) = 0, "", Format(datas(lig, 9) / 1440, "hh:mm"))
fiche.pointage4 = IIf(datas(lig, 10) = 0, "", Format(datas(lig, 10) / 1440, "hh:mm"))
fiche.pointage5 = IIf(datas(lig, 11) = 0, "", Format(datas(lig, 11) / 1440, "hh:mm"))
fiche.pointage6 = IIf(datas(lig, 12) = 0, "", Format(datas(lig, 12) / 1440, "hh:mm"))
fiche.fin = String(23, " ") & ";"
fiche.cr = vbCrLf ' modifier si besoin
Put numfich, lig, fiche ' lig = n° d'enregistrement
Next lig
Close #numfich
End Sub