Here is the situation. I am using the following if statement:
=IF(CD1="Plant", ShowPicD("k:\Downloads\Files\4-13-2016\A1.jpg"), IF(CD1="6200", ShowPicD("k:\Downloads\Files\4-13-2016\A2.jpg"), IF(CD1="6300", ShowPicD("k:\Downloads\Files\4-13-2016\Not Pictured.jpg"),"Not Pictured")))
First, when selecting "Plant" in CD1, it will bring in the picture. However, when picking "6200" it is not getting the second picture (same if I pick the 6300). Also, I am using the following function code, obtained from "http://www.mrexcel.com/forum/excel-ques ... rmula.html"
The code is supposed to delete the picture (if one is there) so we do not get stacked images.
Code: Select all
Function ShowPicD(PicFile As String) As Boolean
'Same as ShowPic except deletes previous picture when picfile changes
Dim AC As Range
Static P As Shape
On Error GoTo Done
Set AC = Application.Caller
If PicExists(P) Then
P.Delete
Else
'look for a picture already over cell
For Each P In ActiveSheet.Shapes
If P.Type = msoLinkedPicture Then
If P.Left >= AC.Left And P.Left < AC.Left + AC.Width Then
If P.Top >= AC.Top And P.Top < AC.Top + AC.Height Then
P.Delete
Exit For
End If
End If
End If
Next P
End If
Set P = ActiveSheet.Shapes.AddPicture(PicFile, True, True, AC.Left, AC.Top, 200, 200)
ShowPicD = True
Exit Function
Done:
ShowPicD = False
End Function
Function PicExists(P As Shape) As Boolean
'Return true if P references an existing shape
Dim ShapeName As String
On Error GoTo NoPic
If P Is Nothing Then GoTo NoPic
ShapeName = P.Name
PicExists = True
NoPic:
PicExists = False
End Function
Brad