Bonsoir Pascal,
Une proposition de code à ajouter à ton excel :
Sub splitAgent()
Dim oSheetPrincipal As Worksheet, oSheet As Worksheet
Dim oCellAgent As Range, oRowDates As Range, oColAgents As Range, oRange As Range
Dim iIncrement As Integer, lRow As Long
Set oSheetPrincipal = ThisWorkbook.Worksheets("Feuil1")
Set oRowDates = oSheetPrincipal.UsedRange.Rows(1)
Set oColAgents = oSheetPrincipal.UsedRange.Columns(1)
For Each oCellAgent In oColAgents.Cells
If IsNumeric(oCellAgent.Value) Then
Set oSheet = ThisWorkbook.Worksheets(Trim(CStr(oCellAgent.Value)))
'On supprime les données de la feuille agent s'il y en a
oSheet.UsedRange.EntireRow.Delete
lRow = 1
iIncrement = 2
For iIncrement = 2 To oRowDates.Columns.Count Step 7
'Recopie des dates d'une semaine
Set oRange = oRowDates.Range(oRowDates.Cells(1, iIncrement), oRowDates.Cells(1, iIncrement + 6))
oRange.Copy oSheet.Cells(lRow, 2)
'Recopie des données de la semaine
lRow = lRow + 1
Set oRange = oSheetPrincipal.Range(oSheetPrincipal.Cells(oCellAgent.Row, iIncrement), oSheetPrincipal.Cells(oCellAgent.Row, iIncrement + 6))
oRange.Copy oSheet.Cells(lRow, 2)
lRow = lRow + 2
Next
End If
Next
'On fait le ménage
Set oColAgents = Nothing
Set oRowDates = Nothing
Set oSheet = Nothing
Set oSheetPrincipal = Nothing
MsgBox "Ventilation des agents terminée!"
End Sub