black_system
XLDnaute Nouveau
Bonjour,
voila j'ai faire une macro sur une page pour insérer une image en fonction d'un résultat qui est sur 2 cellules.Il ne marche pas et le pc me dit qu'il ya une erreur 13.
Voici le code:
Dim objFeuille As Worksheet, objpict As Picture
If Worksheets("HISTO").Range("AG3" And "AI3").Value = 2 And 3 Then
Set objFeuille = ActiveSheet
Set objpict = objFeuille.Pictures.Insert("H:\flèche bas\fleche bas jaune.jpg")
With objpict
.Left = Range("G2").Left
.Top = Range("G2").Top
End With
End If
If Worksheets("HISTO").Range("AG3" And "AI3").Value = 3 And 3 Then
Set objFeuille = ActiveSheet
Set objpict = objFeuille.Pictures.Insert("H:\flèche bas\fleche bas rouge.jpg")
With objpict
.Left = Range("G2").Left
.Top = Range("G2").Top
End With
End If
If Worksheets("HISTO").Range("AG3" And "AI3").Value = 1 And 3 Then
Set objFeuille = ActiveSheet
Set objpict = objFeuille.Pictures.Insert("H:\flèche bas\fleche bas vert.jpg")
With objpict
.Left = Range("G2").Left
.Top = Range("G2").Top
End With
End If
If Worksheets("HISTO").Range("AG3" And "AI3").Value = 2 And 1 Then
Set objFeuille = ActiveSheet
Set objpict = objFeuille.Pictures.Insert("H:\flèche haut\fleche haut jaune.jpg")
With objpict
.Left = Range("G2").Left
.Top = Range("G2").Top
End With
End If
If Worksheets("HISTO").Range("AG3" And "AI3").Value = 3 And 1 Then
Set objFeuille = ActiveSheet
Set objpict = objFeuille.Pictures.Insert("H:\flèche haut\fleche haut rouge.jpg")
With objpict
.Left = Range("G2").Left
.Top = Range("G2").Top
End With
End If
If Worksheets("HISTO").Range("AG3" And "AI3").Value = 1 And 1 Then
Set objFeuille = ActiveSheet
Set objpict = objFeuille.Pictures.Insert("H:\flèche bas\fleche haut vert.jpg")
With objpict
.Left = Range("G2").Left
.Top = Range("G2").Top
End With
End If
If Worksheets("HISTO").Range("AG3" And "AI3").Value = 2 And 2 Then
Set objFeuille = ActiveSheet
Set objpict = objFeuille.Pictures.Insert("H:\flèche cste\fleche cste jaune.jpg")
With objpict
.Left = Range("G2").Left
.Top = Range("G2").Top
End With
End If
If Worksheets("HISTO").Range("AG3" And "AI3").Value = 3 And 2 Then
Set objFeuille = ActiveSheet
Set objpict = objFeuille.Pictures.Insert("H:\flèche cste\fleche cste rouge.jpg")
With objpict
.Left = Range("G2").Left
.Top = Range("G2").Top
End With
Else
Set objFeuille = ActiveSheet
Set objpict = objFeuille.Pictures.Insert("H:\flèche cste\fleche cste vert.jpg")
With objpict
.Left = Range("G2").Left
.Top = Range("G2").Top
End With
End If
End Sub
merci de me dire ce qui ne va pas.ca m'aiderai beaucoup.
voila j'ai faire une macro sur une page pour insérer une image en fonction d'un résultat qui est sur 2 cellules.Il ne marche pas et le pc me dit qu'il ya une erreur 13.
Voici le code:
Dim objFeuille As Worksheet, objpict As Picture
If Worksheets("HISTO").Range("AG3" And "AI3").Value = 2 And 3 Then
Set objFeuille = ActiveSheet
Set objpict = objFeuille.Pictures.Insert("H:\flèche bas\fleche bas jaune.jpg")
With objpict
.Left = Range("G2").Left
.Top = Range("G2").Top
End With
End If
If Worksheets("HISTO").Range("AG3" And "AI3").Value = 3 And 3 Then
Set objFeuille = ActiveSheet
Set objpict = objFeuille.Pictures.Insert("H:\flèche bas\fleche bas rouge.jpg")
With objpict
.Left = Range("G2").Left
.Top = Range("G2").Top
End With
End If
If Worksheets("HISTO").Range("AG3" And "AI3").Value = 1 And 3 Then
Set objFeuille = ActiveSheet
Set objpict = objFeuille.Pictures.Insert("H:\flèche bas\fleche bas vert.jpg")
With objpict
.Left = Range("G2").Left
.Top = Range("G2").Top
End With
End If
If Worksheets("HISTO").Range("AG3" And "AI3").Value = 2 And 1 Then
Set objFeuille = ActiveSheet
Set objpict = objFeuille.Pictures.Insert("H:\flèche haut\fleche haut jaune.jpg")
With objpict
.Left = Range("G2").Left
.Top = Range("G2").Top
End With
End If
If Worksheets("HISTO").Range("AG3" And "AI3").Value = 3 And 1 Then
Set objFeuille = ActiveSheet
Set objpict = objFeuille.Pictures.Insert("H:\flèche haut\fleche haut rouge.jpg")
With objpict
.Left = Range("G2").Left
.Top = Range("G2").Top
End With
End If
If Worksheets("HISTO").Range("AG3" And "AI3").Value = 1 And 1 Then
Set objFeuille = ActiveSheet
Set objpict = objFeuille.Pictures.Insert("H:\flèche bas\fleche haut vert.jpg")
With objpict
.Left = Range("G2").Left
.Top = Range("G2").Top
End With
End If
If Worksheets("HISTO").Range("AG3" And "AI3").Value = 2 And 2 Then
Set objFeuille = ActiveSheet
Set objpict = objFeuille.Pictures.Insert("H:\flèche cste\fleche cste jaune.jpg")
With objpict
.Left = Range("G2").Left
.Top = Range("G2").Top
End With
End If
If Worksheets("HISTO").Range("AG3" And "AI3").Value = 3 And 2 Then
Set objFeuille = ActiveSheet
Set objpict = objFeuille.Pictures.Insert("H:\flèche cste\fleche cste rouge.jpg")
With objpict
.Left = Range("G2").Left
.Top = Range("G2").Top
End With
Else
Set objFeuille = ActiveSheet
Set objpict = objFeuille.Pictures.Insert("H:\flèche cste\fleche cste vert.jpg")
With objpict
.Left = Range("G2").Left
.Top = Range("G2").Top
End With
End If
End Sub
merci de me dire ce qui ne va pas.ca m'aiderai beaucoup.