| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 
 | Sub AutoEcriture()
Dim Lig As Integer, Wb As Workbook
 
Set Wb = ThisWorkbook ' Workbooks.Open("LeFichier")
With Wb.VBProject.VBComponents("Feuil1").CodeModule
    Lig = 1
    .InsertLines Lig, "Private Sub Worksheet_Change(ByVal Target As Range)": Lig = Lig + 1
    .InsertLines Lig, "Dim TabVal(): TabVal = Array(""Serious"", ""Extreme"", ""Low"", ""Moderate"")": Lig = Lig + 1
    .InsertLines Lig, "Dim TabCoul(): TabCoul = Array(6, 3, 35, 34)": Lig = Lig + 1
    .InsertLines Lig, "With Target": Lig = Lig + 1
    .InsertLines Lig, ".Interior.ColorIndex = -4142": Lig = Lig + 1
    .InsertLines Lig, "On Error Resume Next": Lig = Lig + 1
    .InsertLines Lig, "If .Address = ""$D$38"" Then .Interior.ColorIndex = TabCoul(Application.Match(.Value, TabVal, False) - 1)": Lig = Lig + 1
    .InsertLines Lig, "End With": Lig = Lig + 1
    .InsertLines Lig, "End Sub": Lig = Lig + 1
End With
 
End Sub | 
Partager