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 73
| Sub faitotalonglet()
'---------------------------------------------------------------------------------------
'Macro qui copie toutes les lignes (hormis les intitulés de colonne) de tous les onglets
'et créer un nouvel onglet "TOTAL" composé de l'ensemble des lignes
'---------------------------------------------------------------------------------------
Dim Fe As Worksheet
Dim Plage As Range
Dim t(16) As String
'Initialisation des intitulés de colonne
t(1) = "CSP"
t(2) = "N° Formation"
t(3) = "Intitulé1"
t(4) = "Intitulé2"
t(5) = "Objectifs1"
t(6) = "Objectifs2"
t(7) = "Moyen_evaluation1"
t(8) = "Moyen_evaluation2"
t(9) = "Organisme1"
t(10) = "Organisme2"
t(11) = "Début_session1"
t(12) = "Début_session2"
t(13) = "Statut"
t(14) = "Catégorie"
t(15) = "Nom"
t(16) = "Prénom"
'Création d'un nouvel onglet TOTAL
Sheets.Add After:=Sheets(Sheets.Count)
ActiveSheet.Name = "TOTAL"
'chargement des intitulés de colonne
For i = 1 To 16
Cells(1, i).Value = t(i)
Next
'Mise en forme des intitulés
Range("A1:P1").Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorDark1
.TintAndShade = -0.149998474074526
.PatternTintAndShade = 0
End With
With Selection.Borders
.LineStyle = xlContinuous
.Weight = xlThin
End With
With Selection
.HorizontalAlignment = xlCenter
End With
'Parcours la collection en évitant la feuille "TOTAL"
For Each Fe In ThisWorkbook.Worksheets
If Fe.Name <> "TOTAL" Then
With Fe
'définie la plage sans la ligne de titres
Set Plage = .Range(.Cells(2, 1), .Cells(.Cells.Find("*", .[A1], -4123, , 1, 2).Row, .Cells.Find("*", .[A1], -4123, , 2, 2).Column))
End With
'colle les valeurs dans la feuille "TOTAL"
'après la dernière ligne non vide
Plage.Copy Worksheets("TOTAL").Range("A65500").End(xlUp).Offset(1, 0)
End If
Next Fe
End Sub |
Partager