Option Explicit
Sub Extraire()
Dim Titre, dt As Integer, ws As Worksheet, cel As Range, n As Integer
Set ws = ThisWorkbook.Worksheets("tableau")
Titre = Array("DATE", "LIBELLE FORMATION", "SALLE", "ORGANISME /FORMATEUR", "REFERENT ACADEMIE", "PC")
ws.Range("a1").CurrentRegion.ClearContents
ws.Range("a1").Resize(1, 6) = Titre
With Sheets("extraction")
For Each cel In .Range("A2:A" & .Range("A" & Rows.Count).End(xlUp).Row)
If IsDate(cel.Offset(, 6)) And IsDate(cel.Offset(, 7)) Then
If cel.Offset(, 6) <> cel.Offset(, 7) Then
n = DateDiff("d", cel.Offset(, 6).Value2, cel.Offset(, 7).Value2)
If n > 0 Then
dt = ws.Cells(Rows.Count, 1).End(xlUp).Row + 1
For n = 0 To n
ws.Range("A" & dt + n) = cel.Offset(, 6).Value2 + n
ws.Range("A" & dt + n).NumberFormat = "m/d/yyyy"
ws.Range("B" & dt + n) = cel.Offset(, 3)
ws.Range("C" & dt + n) = cel.Offset(, 1)
ws.Range("E" & dt + n) = cel.Offset(, 4)
Next n
Else
If cel.Offset(, 8) = "Validée" Then
dt = ws.Cells(Rows.Count, 1).End(xlUp).Row + 1
ws.Range("A" & dt) = cel.Offset(, 6).Value2
ws.Range("A" & dt).NumberFormat = "m/d/yyyy"
ws.Range("B" & dt) = cel.Offset(, 3)
ws.Range("C" & dt) = cel.Offset(, 1)
ws.Range("E" & dt) = cel.Offset(, 4)
End If
End If
End If
End If
Next cel
End With
End Sub