Bonjour à tous,

Actuellement en stage, je me suis inspirée d'un projet existant pour gérer le planning des congés.
Le code me parait difficile à comprendre, c'est pourquoi je viens solliciter votre aide.
Le code est le suivant :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
Sub auto_open() 'Ouverture automatique
   On Error Resume Next
   Application.CommandBars("BarreColoriage").Delete
   CommandBars.Add ("BarreColoriage")
   CommandBars("BarreColoriage").Visible = True
   For i = 1 To Application.CountA([MesCouleurs]) + 1
      Set bouton = CommandBars("BarreColoriage").Controls.Add(Type:=msoControlButton)
      bouton.Style = msoButtonCaption
      bouton.Tag = Range("MotifsCongés")(i)
      bouton.OnAction = "'Coloriage """ & i & """'"
      bouton.Caption = Range("MesCouleurs")(i)
   Next i
End Sub
Sub Coloriage(p)
   Application.Calculation = xlCalculationManual
   Application.ScreenUpdating = False
   For Each c In Selection
         c.Value = Range("MesCouleurs")(p).Value
         ' C.Interior.ColorIndex = Range("MesCouleurs")(p).Interior.ColorIndex
         Range("MesCouleurs")(p).Copy c
         If Range("MotifsCongés")(p) <> "" Then
             If c.Comment Is Nothing Then c.AddComment ' Création des  commentaires
             c.Comment.Shape.OLEFormat.Object.Font.Name = "Tverdana" 'Définis la police
             c.Comment.Shape.OLEFormat.Object.Font.Size = 7 'Défini la taille de la police
             c.Comment.Shape.OLEFormat.Object.Font.FontStyle = "Normal" 'Défini le style de la police
             temp = Range("MotifsCongés")(p)
             c.Comment.Text Text:=temp
             c.Comment.Shape.TextFrame.AutoSize = True
             c.Comment.Visible = False
         Else
             c.ClearComments
         End If
    Next c
    Application.Calculation = xlCalculationAutomatic
End Sub
Sub auto_close()
    On Error Resume Next
    Application.CommandBars("BarreColoriage").Delete
End Sub
Merci d'avance à ceux qui auront pris le temps de m'aider.

Au plaisir de vous lire

Aphroditeuh