Sub Ajout_feuilles()
Application.ScreenUpdating = False
Sheets("TAB_CTR").Visible = True
Sheets("TAB_CTR").Rows("9:10").EntireRow.Hidden = False
Dim curRange As Range
With Sheets("Fichier source")
Set curRange = .Columns(3).SpecialCells(xlCellTypeConstants)
End With
Dim i As Integer
i = 1
While curRange.Cells(i, 1).Value <> vbNullString
Dim sheetName As String
sheetName = curRange.Cells(i, 1).Value
If Not SheetExists(sheetName) Then
ThisWorkbook.Sheets("TAB_CTR").Copy After:=ThisWorkbook.Sheets(ThisWorkbook.Sheets.Count)
ThisWorkbook.Sheets(ThisWorkbook.Sheets.Count).Name = sheetName
End If
Range("C13").Select
ActiveSheet.PivotTables("Tableau croisé dynamique4").PivotFields("Code" _
).ClearAllFilters
On Error Resume Next
ActiveSheet.PivotTables("Tableau croisé dynamique4").PivotFields("Code" _
).CurrentPage = ActiveWorkbook.ActiveSheet.Name
On Error Resume Next
ActiveSheet.PivotTables("Tableau croisé dynamique4").PivotCache.Refresh
Columns("C:C").EntireColumn.AutoFit
Columns("B:B").EntireColumn.AutoFit
Rows("9:10").Select
Selection.EntireRow.Hidden = True
Range("c4").Select
i = i + 1
Wend
ThisWorkbook.Sheets("Fichier source").Select
Sheets("TAB_CTR").Select
Rows("9:10").Select
Selection.EntireRow.Hidden = True
Range("c4").Select
Application.ScreenUpdating = True
MsgBox ("Les tableaux sont crées")
End Sub