OVH Cloud OVH Cloud

forme automatique avec propriete d'une cellule

16 réponses
Avatar
magic-dd
bonsoir =E0 tous et encore bonne ann=E9e

voila mon souci

j'aimerais qu'une forme automatique cree =E0 partir de l'outil dessin,
notemment un cercle prenne la valeur d'une cellule, et aussi la
couleur de cette cellule

exemple

en A1 j'ai 100 % avec un fond vert, il faudrait que mon "elipse 1 "
soit avec un fond vert et =E0 l'interieur le texte1

j'ai deja essay=E9 avec un label mais le probleme est que le label n'a
qu'une forme rectangulaire alors que je veux un cercle.

merci pour votre aide

6 réponses

1 2
Avatar
magic-dd
merci beaucoup isabelle

cependant si je change les valurs de MFC cela ne fonctionne plus

il m mets erreur 9

je ne comprends pas pourquoi indice en dehors de la selection.
Avatar
isabelle
bonjour magic,

je ne comprend pas, je test avec 1, 2 ou 3 et cela fonctionne.

isabelle

merci beaucoup isabelle

cependant si je change les valurs de MFC cela ne fonctionne plus

il m mets erreur 9

je ne comprends pas pourquoi indice en dehors de la selection.





Avatar
magic-dd
oui en effet ca fonctionne seulement si je change les valeurs de mfc

par exemple mfc(1) rouge si la valeur est entre 0 et 10

mfc(2) orange entre 11 et 15

mfc(3) vert entre 16 et 20

voila essye de changer pour voir

dans l'attente de ta reponse
Avatar
isabelle
bonjour magic,

il faut bien entendu adapter la macro selon les mfc,

par exemple avec ces nouvelles données
tu pourrais modifier la macro comme ca :

Sub Macro1()
If [C10] >= 1 Or [C10] <= 30 Then 'adapter les conditions à la mfc

With ActiveSheet.Shapes("Oval 3").OLEFormat.Object
.Interior.ColorIndex = Range("C10").FormatConditions(Range("C10")).Interior.ColorIndex
End With

With ActiveSheet.Shapes("Text Box 5").OLEFormat.Object.Characters
.Text = Range("C10")
.Font.Name = Range("C10").Font.Name
.Font.Size = Range("C10").Font.Size
.Font.Italic = Range("C10").Font.Italic
.Font.FontStyle = Range("C10").Font.FontStyle
.Font.Strikethrough = Range("C10").Font.Strikethrough
.Font.Superscript = Range("C10").Font.Superscript
.Font.Subscript = Range("C10").Font.Subscript
.Font.OutlineFont = Range("C10").Font.OutlineFont
.Font.Shadow = Range("C10").Font.Shadow
.Font.Underline = Range("C10").Font.Underline
.Font.ColorIndex = Range("C10").Font.ColorIndex
End With

With ActiveSheet.Shapes("Text Box 5").OLEFormat.Object
.HorizontalAlignment = Range("C10").HorizontalAlignment
.VerticalAlignment = Range("C10").VerticalAlignment
.ReadingOrder = Range("C10").ReadingOrder
.Orientation = Range("C10").Orientation
End With

Else
ActiveSheet.Shapes("Oval 3").OLEFormat.Object.Interior.ColorIndex = xlNone
End If

End Sub

isabelle

oui en effet ca fonctionne seulement si je change les valeurs de mfc

par exemple mfc(1) rouge si la valeur est entre 0 et 10

mfc(2) orange entre 11 et 15

mfc(3) vert entre 16 et 20

voila essye de changer pour voir

dans l'attente de ta reponse



Avatar
isabelle
correction :

Sub Macro1()
Select Case [C10]
Case 1 To 10: x = 1
Case 11 To 20: x = 2
Case 21 To 30: x = 3
Case Else
ActiveSheet.Shapes("Oval 3").OLEFormat.Object.Interior.ColorIndex = xlNone
Exit Sub
End Select

With ActiveSheet.Shapes("Oval 3").OLEFormat.Object
.Interior.ColorIndex = Range("C10").FormatConditions(x).Interior.ColorIndex
End With

With ActiveSheet.Shapes("Text Box 5").OLEFormat.Object.Characters
.Text = Range("C10")
.Font.Name = Range("C10").Font.Name
.Font.Size = Range("C10").Font.Size
.Font.Italic = Range("C10").Font.Italic
.Font.FontStyle = Range("C10").Font.FontStyle
.Font.Strikethrough = Range("C10").Font.Strikethrough
.Font.Superscript = Range("C10").Font.Superscript
.Font.Subscript = Range("C10").Font.Subscript
.Font.OutlineFont = Range("C10").Font.OutlineFont
.Font.Shadow = Range("C10").Font.Shadow
.Font.Underline = Range("C10").Font.Underline
.Font.ColorIndex = Range("C10").Font.ColorIndex
End With

With ActiveSheet.Shapes("Text Box 5").OLEFormat.Object
.HorizontalAlignment = Range("C10").HorizontalAlignment
.VerticalAlignment = Range("C10").VerticalAlignment
.ReadingOrder = Range("C10").ReadingOrder
.Orientation = Range("C10").Orientation
End With

End Sub


isabelle

oui en effet ca fonctionne seulement si je change les valeurs de mfc

par exemple mfc(1) rouge si la valeur est entre 0 et 10

mfc(2) orange entre 11 et 15

mfc(3) vert entre 16 et 20

voila essye de changer pour voir

dans l'attente de ta reponse



Avatar
magic-dd
bonjour isabelle

tout est parfait maintenant

tu as maitrisé la solution parfaitement et m'as fait progressé dans
mon aprentissage de vba.

un grand merci à toi

loic
1 2