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 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
| Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Row >= 8 And Target.Row <= 38 And Target.Column = 8 Then
ActiveSheet.Unprotect "admin"
Dim lig As Integer
Dim temp As String
Dim temp2 As String
lig = Target.Row
temp = "I" & lig & ":N" & lig
Range(temp).Select
Selection.Locked = False
Selection.FormulaHidden = False
'On vide les cases de la colonne I à N
Cells(lig, 9).Value = ""
Cells(lig, 10).Value = ""
Cells(lig, 11).Value = ""
Cells(lig, 12).Value = ""
Cells(lig, 13).Value = ""
Cells(lig, 14).Value = ""
If lig Mod 2 = 0 Then 'Si la ligne est paire
With Selection.Interior 'On colorie le fond en blanc
.Pattern = xlSolid ' C'est ici que le compilo indique une erreur, ( si la ligne sélectionnée est paire, sinon c'est un peu plus bas ) sachant que le code en lui-même fonctionne parfaitement, puisqu'il provient d'un enregistrement, et fonctionne si on l'exécute en solo
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorDark1
.TintAndShade = 0
.PatternTintAndShade = 0
End With
Else 'Si la ligne est impaire
With Selection.Interior 'On colorie le fond en bleu clair
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorAccent1
.TintAndShade = 0.799981688894314
.PatternTintAndShade = 0
End With
End If
'Cas n°1, que le compilo n'atteind plus...
If Cells(lig, 8).Value = "Autres frais de séjour avec repas midi" Then
temp = "I" & lig
Range(temp).Select
Selection.Locked = True
Selection.FormulaHidden = True
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorLight2
.TintAndShade = 0.599993896298105
.PatternTintAndShade = 0
End With
Cells(lig, 11).Value = 1
Cells(lig, 12).Value = 0
Cells(lig, 13).Value = 0
Cells(lig, 14).Value = 0
temp = "L" & lig & ":N" & lig
Range(temp).Select
Selection.Locked = True
Selection.FormulaHidden = True
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorAccent5
.TintAndShade = 0.599993896298105
.PatternTintAndShade = 0
End With
End If
'Suivent ensuite les 30 autres cas, ainsi que la fin du programme :
Range("H8").Select
ActiveSheet.Protect "admin", True, True, True
End Sub |
Partager