Bonjour le Forum,
Un bout de code donné par ODVJ ce matin m'a permis d'avancer dans mon fichier. Cependant je voulais mettre une condition pour effectuer les calculs, je colorie en vert les cellules modifiées, si le coefficient (par rapport à target, R2C ou R2C[1] selon le cas) est différent 0, dans le cas contraire je colorie en vert mais pas de calcul.
Merci de votre aide
Private Sub Worksheet_Change(ByVal Target As Range)
Dim lig As Byte
'For x = 3 To 20
If Not Application.Intersect(Target, Range("A3:A20,E3:E20")) Is Nothing Then
'If Not Application.Intersect(Target, Range("A3:A" & x ",E3:E "& " x")) Is Nothing Then
Application.EnableEvents = False
Target.Interior.ColorIndex = 4
If "R2C" > 0 Then
Target.Offset(0, 1).FormulaR1C1 = "=RC[-1]*R2C"
End If
Target.Offset(0, 1).Interior.ColorIndex = -4142
Application.EnableEvents = True
Exit Sub
End If
If Not Application.Intersect(Target, Range("B3:B20,F3:F20")) Is Nothing Then
Application.EnableEvents = False
Target.Interior.ColorIndex = 4
If "R2C[1]" > 0 Then
Target.Offset(0, -1).FormulaR1C1 = "=RC[1]/R2C[1]"
End If
Target.Offset(0, -1).Interior.ColorIndex = -4142
Application.EnableEvents = True
Exit Sub
End If
End Sub
Un bout de code donné par ODVJ ce matin m'a permis d'avancer dans mon fichier. Cependant je voulais mettre une condition pour effectuer les calculs, je colorie en vert les cellules modifiées, si le coefficient (par rapport à target, R2C ou R2C[1] selon le cas) est différent 0, dans le cas contraire je colorie en vert mais pas de calcul.
Merci de votre aide
Private Sub Worksheet_Change(ByVal Target As Range)
Dim lig As Byte
'For x = 3 To 20
If Not Application.Intersect(Target, Range("A3:A20,E3:E20")) Is Nothing Then
'If Not Application.Intersect(Target, Range("A3:A" & x ",E3:E "& " x")) Is Nothing Then
Application.EnableEvents = False
Target.Interior.ColorIndex = 4
If "R2C" > 0 Then
Target.Offset(0, 1).FormulaR1C1 = "=RC[-1]*R2C"
End If
Target.Offset(0, 1).Interior.ColorIndex = -4142
Application.EnableEvents = True
Exit Sub
End If
If Not Application.Intersect(Target, Range("B3:B20,F3:F20")) Is Nothing Then
Application.EnableEvents = False
Target.Interior.ColorIndex = 4
If "R2C[1]" > 0 Then
Target.Offset(0, -1).FormulaR1C1 = "=RC[1]/R2C[1]"
End If
Target.Offset(0, -1).Interior.ColorIndex = -4142
Application.EnableEvents = True
Exit Sub
End If
End Sub