View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
John Bundy John Bundy is offline
external usenet poster
 
Posts: 772
Default DISPLAY Image Based on Logic

Try this

Add a module in excel:



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



To use this, you will type this in the cell:

=ShowPicD()



You place the location of the file in the ( ).


--
-John
Please rate when your question is answered to help us and others know what
is helpful.


"RayportingMonkey" wrote:

I need to display a number of corporate logos on a report I am creating. The
report(s) run from a single template, so I want to be able to DISPLAY (not
hyperlink) the appropriate logo, based on a cell's content.

Is this even possible?

Thanks!
Ray