Bonjour,
Je souhaiterai colorier des formes en fonction de la valeur d'une cellule. J'ai créer ce code ci :
If Cells(1, 2).Value = 1 Then
ActiveSheet.Shapes("Ellipse2").Select
Selection.ShapeRange.Fill.ForeColor.RGB = RGB(240, 230, 28) 'jaune
ElseIf Cells(1, 2) = 2 Then
ActiveSheet.Shapes("Ellipse2").Select
Selection.ShapeRange.Fill.ForeColor.RGB = RGB(195, 174, 206) 'violet
ElseIf Cells(1, 2).Value = 3 Then
ActiveSheet.Shapes("Ellipse2").Select
Selection.ShapeRange.Fill.ForeColor.RGB = RGB(151, 215, 115) 'vert clair
La prochaine étape serait de créer une boucle pour faire ceci sur toutes les formes de ellipse1, à ellipse50.
J'ai utilisé le code suivant, mais il y a un problème sur la fonction shape. Je pense que je me trompe sur le formalisme, mais je ne trouve pas la solution.
Dim x As Integer
For x = 1 To 50
If Cells(1, x).Value = 1 Then
ActiveSheet.Shapes("Ellipsex").Select
Selection.ShapeRange.Fill.ForeColor.RGB = RGB(240, 230, 28) 'jaune
ElseIf Cells(1, x) = 2 Then
ActiveSheet.Shapes("Ellipsex").Select
Selection.ShapeRange.Fill.ForeColor.RGB = RGB(195, 174, 206) 'violet
ElseIf Cells(1, x).Value = 3 Then
ActiveSheet.Shapes("Ellipsex").Select
Selection.ShapeRange.Fill.ForeColor.RGB = RGB(151, 215, 115) 'vert clair
End If
Next x
Merci pour votre aide.