1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
| For i = 2 To 2000 ' boucle qui lit une liste de noms
If Range("A" & i) = "" Or Range("A" & i) = " " Then GoTo fin1
responsable = Range("A" & i).Value
Windows(Fichier).Activate
Sheets(feuille).Select
' extraction des données concernant le nom
Columns("A:A").Select
Selection.AutoFilter
Selection.AutoFilter Field:=1, Criteria1:=responsable
Range("A1").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Windows("temporaire.xls").Activate
'copie des données sur une feuille, je peux avoir 50 feuilles ou plus
'au bout de 20 feuilles inserees de maniere correcte CRASH
On Error GoTo aerreur
aerreur: Sheets.Add before:=Sheets("WORK")
Range("A1").Value = "Responsable : " & responsable
Range("A3").Select
ActiveSheet.Paste
ActiveSheet.Name = responsable
'totaux par feuille responsable
Selection.Subtotal GroupBy:=1, Function:=xlSum, TotalList:=Array(8, 9, 10, 11, 12, 13 _
, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27), Replace:=True, PageBreaks:=False, SummaryBelowData:=True
Columns("H:AA").Select
Selection.NumberFormat = "0.00"
'recherche ligne total pour la copier en l1
For i3 = 1 To 1000
'recherche ligne total
If InStr(1, Range("A" & i3), "Total", vbTextCompare) = 0 Then GoTo suitx
Range("A" & i3 & ":" & "BB" & i3).Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.Copy
Range("A" & i3).Select
'copie ligne total valeur
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("A" & i3 & ":" & "BB" & i3).Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.Cut
'insertion ligne total en ligne 1 pour suppression de colonne si = 0
Rows("1:1").Select
Selection.Insert Shift:=xlDown
' Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
' :=False, Transpose:=False
i5 = 27
For i4 = 8 To 27
If Cells(1, i5) = 0 Then Columns(i5).Delete
i5 = i5 - 1
Next i4
Rows("1:1").Select
Selection.Delete Shift:=xlUp
GoTo suity
suitx: Next i3
suity:
Windows("temporaire.xls").Activate
Sheets("WORK").Select
'recherche responsable suivant
ActiveWorkbook.SaveAs Filename:=temporaire _
, FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
Next i |
Partager