Hello,
Please help me to display an image in a cell depending on the choice in a dropdown list.
I did several searches but I can not ... (I’m a beginner in VBA)
The combo is in cell B1 and depending on the choice, I would like the image displayed in the cell C. (ex: fruit 1, fruit 1 image, 2 fruit, fruit Image 2 ...). The images are in a directory on the C: \
I have two problems with the code attached:
1. It displays all the images regardless of the choice (I can not write the condition for an image display with a choice ..)
2. It does not display the code within the specified cell, in this case, the G1.
Thank you very much for your help!
Any suggestions would be greatly appreciated!
here is the code :
If Target.Address = "$B$1" Then
With ActiveSheet
Set pic1 = .Pictures.Insert("C:\fruits\fruit1.jpg")
With pic1
.Name = "fruit1"
.Width = 100
.Height = 100
.Top = ActiveSheet.Range("G1").Top
.Left = ActiveSheet.Range("G1").Left
End With
Set pic2 = .Pictures.Insert("C:\fruits\fruit2.jpg")
With pic2
.Name = "fruit2"
.Width = 100
.Height = 100
.Top = ActiveSheet.Range("G1").Top
.Left = ActiveSheet.Range("G1").Left
End With
Set pic3 = .Pictures.Insert("C:\fruits\fruit3.jpg")
With pic3
.Name = "fruit3"
.Width = 100
.Height = 100
.Top = ActiveSheet.Range("G1").Top
.Left = ActiveSheet.Range("G1").Left
End With
End With
End If
End Sub
Bookmarks