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
| Sub LigneTaches()
Dim Dat1 As Date, kR As Long, kRprj As Long, sPrj As String
Dim kC1 As Long, kC2 As Long
Dat1 = Range("I3").Value '--- date intiale
kR = 6 '--- n° première ligne de données
Do
If Cells(kR, 5) = "" Then '--- 5 = n° colonne Phase
'--- tâche vide => est une ligne de titre du groupe
sPrj = Cells(kR, 4) '--- 4 = n° colonne Nom projet
kRprj = kR
Else
'--- tâche mentionnée => reporter dans ligne titre du groupe
If Cells(kR, 8).Value >= Dat1 Then '--- 8 = n° colonne date Fin
If Cells(kR, 7).Value < Dat1 Then '--- 7 = n° colonne date Début
kC1 = 9 '--- 9 = n° colonne première date données
Else
kC1 = Cells(kR, 7).Value - Dat1 + 9
End If
kC2 = Cells(kR, 8).Value - Dat1 + 9
Debug.Print kRprj, kC1, kC2, Cells(kR, 5).Value
Cells(kRprj, kC1).Value = Cells(kR, 5).Value
FormatCellule Range(Cells(kRprj, kC1), Cells(kRprj, kC2)), Cells(kR, 6).Value
End If
End If
kR = kR + 1
Loop Until Cells(kR, 4) = ""
End Sub
Sub FormatCellule(r As Range, sStatut As String)
With r.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = -(10079487 * (sStatut = "Etudes") + 13408767 * (sStatut = "Concours") + 6750105 * (sStatut = "Vacances"))
.TintAndShade = 0
.PatternTintAndShade = 0
End With
End Sub |
Partager