How to insert and load an image for Excel 2003?

E

Eric

Does anyone have any suggestions on how to display image based on if-condition?
I have insert an image into excel, and I would like to set an if statement
to display this image, does anyone have any suggestions on how to insert
those images into excel, and how to load it in Excel 2003?
Thanks in advance for any suggestions
Eric
 
J

Jacob Skaria

Select the sheet tab which you want to work with. Right click the sheet tab
and click on 'View Code'. This will launch VBE. Paste the below code to the
right blank portion. Edit the pciture path and get back to to worksheet and
enter 1 in cell A1..If you enter anything else the pickture will be
removed.....

Private Sub Worksheet_Change(ByVal Target As Range)
Dim myPic As Object
If Range("A1") = 1 Then
Set myPic = ActiveSheet.Pictures.Insert("C:\TempPic.JPG")
Else
Set myPic = ActiveSheet.Pictures(1)
myPic.Delete
End If

End Sub
 
J

Jacob Skaria

Missed to check the Target Address....

Private Sub Worksheet_Change(ByVal Target As Range)
Dim myPic As Object
If Target.Address = "$A$1" Then
If Range("A1") = 1 Then
Set myPic = ActiveSheet.Pictures.Insert("C:\TempPic.JPG")
Else
Set myPic = ActiveSheet.Pictures(1)
myPic.Delete
End If
End If
End Sub
 
E

Eric

Thank you very much for suggestions
I get 2 images, if A1=1, then 1.gif, else if A1=2, then 2.gif, else nothing.
Do you have any suggestions on how to modify the code to do it?
Thank you very much for any suggestions
Eric
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top