Re : Planning
Bonjour,
je me suis permis, sur le code de Spacegraphiste, qui a été plus rapide sur la même idée, d'ajouter les lignes qui mettent un commentaire dans les celulles concernées si jamais le nom est trop long pour se trouver dans la ligne planning, j'espère que celui-ci ne m'en voudra pas
(lignes 30-40-170-190-200)
Sub Planning()
Dim i As Long, j As Long, k As Long, client As String, salarié As String
Dim dlignejour As Long, dligneplanning As Long, hdebut As Long, hfin As Long, horaire As String
Dim R As String, c As String, couleur As String, c1 As String
Dim mCom As String
10 dlignejour = Sheets("JOUR").Range("A65536").End(xlUp).Row
20 dligneplanning = Sheets("PLANNING").Range("A65536").End(xlUp).Row
Dim Zone As Range
30 Set Zone = Sheets("planning").Range("B2:AW14")
40 Zone.ClearComments
50 For j = 2 To dligneplanning
60 For i = 2 To dlignejour
'Vérifie si le nom est le même
70 If Sheets("JOUR").Cells(i, 4) = Sheets("PLANNING").Cells(j, 1) Then
80 horaire = Format(Sheets("JOUR").Cells(i, 3), "hh:mm:ss")
90 hdebut = (Format(horaire, "h") * 2) + Format(horaire, "n") / 30 + 2
100 horaire = Format(Sheets("JOUR").Cells(i, 6), "hh:mm:ss")
110 hfin = (Format(horaire, "h") * 2) + Format(horaire, "n") / 30 + 2
'Récupère la couleur de cellule
120 R = "G" & i
130 couleur = Sheets("JOUR").Range(R).Interior.Color
140 c = Replace(Left(Sheets("PLANNING").Cells(i, hdebut).Address, 3), "$", "", , , VBA.vbTextCompare)
150 c1 = Replace(Left(Sheets("PLANNING").Cells(i, hfin).Address, 3), "$", "", , , VBA.vbTextCompare)
160 R = c & j & ":" & c1 & j
'Rempli le tableau planning
170 mCom = Sheets("JOUR").Cells(i, 2)
180 Sheets("PLANNING").Cells(j, hdebut) = Sheets("JOUR").Cells(i, 2)
190 Sheets("PLANNING").Cells(j, hdebut).AddComment.Text Text:=mCom
200 Sheets("PLANNING").Cells(j, hdebut).Comment.Shape.TextFrame.AutoSize = True
210 Sheets("PLANNING").Range(R).Interior.Color = couleur
220 End If
230 Next i
240 Next j
End Sub