Results 1 to 3 of 3
  1. #1
    4 Star Lounger
    Join Date
    Jan 2001
    Location
    Atlanta
    Posts
    568
    Thanks
    7
    Thanked 1 Time in 1 Post

    Including Graphics in Formula (97)

    Is it possible to include graphics in a formula? For example, is there some way to accomplish the following:

    =IF(C1=1,ONE.JPG,NO.JPG)

    or

    ="This cell would have a graphic "&GRAPHIC.BMP&" surrounded by text"

    Ronny
    Ronny Richardson

  2. #2
    New Lounger
    Join Date
    May 2002
    Location
    Colorado, USA
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Including Graphics in Formula (97)

    Hi Ronny,

    I'm not aware of any built-in mechanism to do this. Here is a custom user-defined function (UDF) that you can use to accomplish this:

    Function ShowPic(PicFile As String) As Boolean
    Dim AC As Range
    On Error GoTo Done
    Set AC = Application.Caller
    ActiveSheet.Shapes.AddPicture PicFile, True, True, AC.Left, AC.Top, 200, 200
    ShowPic = True
    Exit Function
    Done:
    ShowPic = False
    End Function

    This function will yield a TRUE if the picture is found, false otherwise. It will put the top left corner of the picture in the top left corner of the cell containing the formula. In your example, your could use it like this:

    =IF(C1=1,ShowPic("ONE.JPG"),ShowPic("NO.JPG"))

    Where ONE.JPG ad NO.JPG are .jpg files that reside in the current working folder. If not in the working folder you can give a complete path:

    ShowPic("C:My DocumentsMy Picturesone.jpg")

    I don't know if this is exactly what you want, but if not perhaps it is at least close.

    To install this macro, simply paste the code into a standard macro module (Alt-TMV, then Alt-IM and paste in the code pane).

  3. #3
    5 Star Lounger
    Join Date
    Dec 2000
    Location
    Reading/Swindon, Berkshire, United Kingdom
    Posts
    664
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Including Graphics in Formula (97)

    does this thread help you any?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •