afficher une image selon résultat d'une formule

sebt56

XLDnaute Nouveau
Salut, je voudrai faire apparaitre une image selon le résultat d'un calcul
j'ai testé ceci :
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 8 And Target.Count = 1 Then
'-- suppression
For Each s In ActiveSheet.Shapes
If s.Type = 13 Then
If s.TopLeftCell.Address = Target.Offset(0, 1).Address Then
s.Delete
End If
End If
Next s
'--
If Target <> "" Then
Sheets("Images").Shapes(Target).Copy
Target.Offset(0, 1).Select
ActiveSheet.Paste
Selection.ShapeRange.Left = ActiveCell.Left + 7
Selection.ShapeRange.Top = ActiveCell.Top + 5
Target.Select
End If
End If
End Sub

mais ça ne marche pas avec un résultat comme valeur cible.
Merci
 

Fred0o

XLDnaute Barbatruc
Re : afficher une image selon résultat d'une formule

Bonsoir Sebt56,

J'ai fais un fichier pour tester ton code et essayer de comprendre ton problème. Mon essai fonctionne, vois si cela correspond à ton besoin.
 

Pièces jointes

  • Images.xls
    36 KB · Affichages: 263
  • Images.xls
    36 KB · Affichages: 267
  • Images.xls
    36 KB · Affichages: 270

sebt56

XLDnaute Nouveau
Re : afficher une image selon résultat d'une formule

Merci mais j'ai trouvé une autre solution :

a mettre dans un module

Function AfficheCache(nb, seuil, image)
If nb > seuil Then
ActiveSheet.Shapes(image).Visible = True
Else
ActiveSheet.Shapes(image).Visible = False
End If
AfficheCache = 0
End Function

et ensuite utiliser la formule

=affichecache(F14;1;"nomimage") --> Si f14>1 Affiche nomimage
 

Discussions similaires

Statistiques des forums

Discussions
312 094
Messages
2 085 242
Membres
102 833
dernier inscrit
Hassna