Can I display images on MS Excel by using simple IF ELSE statements

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nr2008
    New Member
    • Feb 2008
    • 1

    Can I display images on MS Excel by using simple IF ELSE statements

    Hi,

    This is not VB programming par se. Am working on MS Excel to display project progress thru some icons. A MS Excel formula is displaying cell content or had coded text, but not images/icons embedded in the worksheet. So I am trying my hand at coding it thru Microsoft Visual Basic and running a macro.

    Can anyone please give me the proper verbiage for a simple If-Else statement which has the following logic:

    If cell A1 > 50%,
    cell A10 will display Icon X
    Else cell A10 will display icon Y

    This is a bit urgent.

    Thanks!
  • Stephen Anderso
    New Member
    • May 2011
    • 1

    #2
    Hi,

    I am trying to do the same - did you ever get an answer to this?

    Comment

    • Guido Geurs
      Recognized Expert Contributor
      • Oct 2009
      • 767

      #3
      Some questions:
      - Is this MS Office 2003 or ...
      - Is the icon a picture in cell A10?

      Comment

      • Guido Geurs
        Recognized Expert Contributor
        • Oct 2009
        • 767

        #4
        This is a macro for Office 2003:
        Code:
        Sub Update_Icons()
            With Sheets("sheet1")
                If Range("A1").Value > 50 Then
                    .ImageA10.Picture = .IconPlus.Picture
                Else
                    .ImageA10.Picture = .IconMin.Picture
                End If
            End With
        End Sub
        ImageA10 is a picturebox in the cell A10.
        IconPlus is a picturebox on the sheet (visible=False)
        IconMin is a picturebox on the sheet (visible=False)

        test:
        - enter a value in A1 (<50 or >50).
        - run the macro => the icon will change according to the value (- = <50, + = >50)
        Attached Files

        Comment

        Working...