Private Sub Worksheet_change(ByVal Target As Range)
Application.ScreenUpdating = False
On Error GoTo 0
On Error Resume Next
If Not Intersect(Target, [q6:q109]) Is Nothing And Target.Count = 1 Then
If Target = 1 Then
Range(Target, Target.Offset(0, -8)).Font.ColorIndex = 3
Else
Range(Target, Target.Offset(0, -8)).Font.ColorIndex = 0
End If
End If
If Not Intersect(Target, [i6:i500]) Is Nothing And Target.Count = 1 Then
ActiveCell.Offset(-1, 0).Activate
If Target = "" Then
Exit Sub
Else
Call Phase
End If
End If
If Not Intersect(Target, [j6:j500]) Is Nothing And Target.Count = 1 Then
Call Sousphase
End If
End Sub
Sub Phase()
Dim Ligne As String, Hierarchie As String
Dim Datedebut As String, Datefin As String, P As String
Dim Nbrejour As String, Datedebutphase As String, Datefinphase As String, Etat As String
Ligne = "=(INDIRECT(ADDRESS((ROW()-1),6,1,1))+1)"
Hierarchie = "=Hierarchie"
P = "=Phase"
' Phase--------------------------------------------------------------
Nbrejour = "=Nbrejour"
Datedebutphase = "=Datedebutphase"
Datefinphase = "=Datefinphase"
Etat = "=Etat"
With ActiveCell
ActiveCell.Offset(0, -3) = Ligne
ActiveCell.Offset(0, -2) = P
ActiveCell.Offset(0, -1) = Hierarchie
ActiveCell.Offset(0, 5) = Nbrejour
ActiveCell.Offset(0, 6) = Datedebutphase
ActiveCell.Offset(0, 7) = Datefinphase
ActiveCell.Offset(0, 8) = Etat
Range(ActiveCell.Offset(0, 0), ActiveCell.Offset(0, 8)).Select
With Selection.Font
.Name = "Arial"
.FontStyle = "Gras"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
With Selection.Interior
.ColorIndex = 15
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
End With
End With
ActiveCell.EntireRow.Cells(1, 1).Activate
ActiveCell.Offset(0, 8).Activate
Exit Sub
End Sub
Sub Sousphase()
Dim Ligne As String, Hierarchie As String
Dim Datedebut As String, Datefin As String, P As String
Ligne = "=(INDIRECT(ADDRESS((ROW()-1),6,1,1))+1)"
Hierarchie = "=Hierarchie"
P = "=Phase"
' Sous phase-------------------------------------------------------------
Datedebut = "=Datedebut"
Datefin = "=Datefin"
With ActiveCell.Offset(-1, 0).Activate
ActiveCell.Offset(0, -4) = Ligne
ActiveCell.Offset(0, -2) = Hierarchie
ActiveCell.Offset(0, 6) = Datefin
ActiveCell.Offset(0, 7) = "0"
If ActiveCell.Offset(-1, -3) > 0 Then
ActiveCell.Offset(0, 5) = ""
Else
ActiveCell.Offset(0, 5) = Datedebut
End If
If ActiveCell.Offset(0, -3) >= 1 Then
Range(ActiveCell.Offset(0, -1), ActiveCell.Offset(0, 7)).Select
With Selection.Font
.Name = "Arial"
.FontStyle = "Normal"
.Size = 8
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
Selection.Interior.ColorIndex = xlNone
ActiveCell.Offset(0, -0) = ""
ActiveCell.Offset(1, -2) = ""
ActiveCell.Offset(1, 5) = ""
ActiveCell.Offset(1, 8) = ""
ActiveCell.EntireRow.Cells(1, 1).Activate
ActiveCell.Offset(1, 9).Activate
End If
End With
End Sub