Enchainement de macros

Cruz

XLDnaute Occasionnel
Bonjour tout le Monde
J'ai une macro du style:
Code:
 Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If Range('A1') = 1 Then
Range('B1').Select
Activesheet.Pictures.Insert(''D:\\1.bmp')
End If

If Range('A2') = 1 Then
Range('B2').Select
Activesheet.Pictures.Insert(''D:\\2.bmp')
End If

If Range('A3') = 1 Then
Range('B3').Select
Activesheet.Pictures.Insert(''D:\\3.bmp')
End If
End Sub


Quand je n'insère qu'un code sur les 3, celui-ci marche.
Mais lorsque les 3 macros doivent s'activer, la première image s'insert, et un message affiche:
Erreur d'execution '-2147417848 (80010108):
La méthode 'Insert' de l'objet 'Pictures' a échoué

aidez-moi svp
merci d'avance a+
cruz
 

CBernardT

XLDnaute Barbatruc
Bonjour Cruz et le forum,

Je te propose un code de ce style :

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Application.Intersect(Target, Range('A1,A2,A3')) Is Nothing Then

ActiveSheet.DrawingObjects.Delete

If Range('A1') = 1 Then
Range('B1').Select
ActiveSheet.Pictures.Insert (''D:\\1.bmp')
End If

If Range('A2') = 1 Then
Range('B2').Select
ActiveSheet.Pictures.Insert (''D:\\2.bmp')
End If

If Range('A3') = 1 Then
Range('B3').Select
ActiveSheet.Pictures.Insert (''D:\\3.bmp')
End If

End If
End Sub

Cordialement

Bernard
 

Discussions similaires

Réponses
1
Affichages
247

Membres actuellement en ligne

Statistiques des forums

Discussions
312 215
Messages
2 086 329
Membres
103 183
dernier inscrit
karelhu35