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 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
| Sub GESTION_TEMPS()
'
' GESTION_TEMPS Macro
'
' Touche de raccourci du clavier: Ctrl+h
'
'
' Déclaration des variables
'
Dim plage As Range, reg As Range, firstAdd As String, cel As Range
'
' Défusion des cellules
'
Cells.Select
With Selection
.VerticalAlignment = xlBottom
.Orientation = 0
.AddIndent = False
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
'
' Separer les différents tableaux avec la position
'
Set plage = Worksheets("export").Cells
Set reg = plage.Find(What:="Sem n°")
If Not reg Is Nothing Then
firstAdd = reg.Address
Do
reg.CurrentRegion.Copy
Sheets.Add After:=ActiveSheet
ActiveSheet.Paste
Set reg = plage.FindNext(reg)
Loop While Not reg Is Nothing And reg.Address <> firstAdd
End If
'
' Réorganisation des tableaux
'
Dim sh As Worksheet
For Each sh In ActiveWorkbook.Sheets
sh.Activate
If sh.Name <> "export" Then
'Changement des noms des feuilles
sh.Name = Right(ActiveSheet.Range("A1").Value, Len(ActiveSheet.Range("A1").Value) - InStr(ActiveSheet.Range("A1").Value, ":"))
Columns("H:H").Select
'Réorga
Selection.Delete Shift:=xlToLeft
Selection.Delete Shift:=xlToLeft
'Début: Mise en place des horaires
Columns("E:E").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Columns("D:D").Select
Application.DisplayAlerts = False
Selection.TextToColumns Destination:=Range("D1"), DataType:=xlFixedWidth, _
FieldInfo:=Array(Array(0, 1), Array(5, 1), Array(7, 1)), TrailingMinusNumbers:= _
True
Application.DisplayAlerts = True
Columns("E:E").Select
Selection.Delete Shift:=xlToLeft
Range("D2").Select
ActiveCell.FormulaR1C1 = "Horaires début"
Range("E2").Select
ActiveCell.FormulaR1C1 = "Horaires fin"
'Mise en place sous-totaux
For Each cel In Range("A3", Range("A3").End(xlDown))
If cel.Value <> cel.Offset(1, 0).Value And cel.Value <> "" And cel.Value <> "Sous-total:" Then 'Ajouter ici toutes les values des cellules de la colonne A pour ne pas faire buguer
cel.Select
Selection.Offset(1).EntireRow.Insert
Selection.Offset(1).Value = "Sous-total:"
Selection.Offset(1).Font.Bold = True
'Selection.Offset(1, 3).FormulaLocal = "=SOUS.TOTAL(9)" https://www.generation-nt .com/reponses/sous-total-vba-entraide-482931.html
With Selection.Offset(1).Resize(1, 12).Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorDark2
.TintAndShade = 0
.PatternTintAndShade = 0
End With
End If
Next cel
' Pour la majoration regarder le select case
End If
Next sh
End Sub |
Partager