Results 1 to 1 of 1

Displaying Images dependant on value of a cell

Threaded View

  1. #1
    Registered User
    Join Date
    03-13-2013
    Location
    Exeter,England
    MS-Off Ver
    Excel 2007
    Posts
    2

    Displaying Images dependant on value of a cell

    Hi,

    After searching for a method on displaying images based on the value of a cell, I stumbled upon a great guide and example sheet at http://www.mcgimpsey.com/excel/lookuppics.html
    This worked great but I now have a problem with the macro.

    I am trying to do similar to the example sheet but I have 5 different drop down lists of names and I want it to display images for each name selected.
    After playing around and managing this my next problem arose.
    If I selected the same name it would hide the image displayed for the previous identical name and I do not wish this to happen.

    The macro used on example is this one
    Formula: copy to clipboard
        Private Sub Worksheet_Calculate()
    Dim oPic As Picture
    Me.Pictures.Visible = False
    With Range("F1")
    For Each oPic In Me.Pictures
    If oPic.Name = .Text Then
    oPic.Visible = True
    oPic.Top = .Top
    oPic.Left = .Left
    Exit For
    End If
    Next oPic
    End With
    End Sub


    F1 references the Cell that displays the name of the picture that it will display.

    I wish it to do this 5 times referencing cells, F1,F2,F3,F4,F5 and therefore displaying 5 pictures but if any of the cells are equal to the other, I don't want it to hide the previous identical cells image.
    My Macro is:-
    Formula: copy to clipboard
        Private Sub Worksheet_Calculate()
    Dim oPic As Picture
    Me.Pictures.Visible = False
    With Range("F1")
    For Each oPic In Me.Pictures
    If oPic.Name = .Text Then
    oPic.Visible = True
    oPic.Top = .Top
    oPic.Left = .Left
    Exit For
    End If
    Next oPic
    End With
    With Range("F2")
    For Each oPic In Me.Pictures
    If oPic.Name = .Text Then
    oPic.Visible = True
    oPic.Top = .Top
    oPic.Left = .Left
    Exit For
    End If
    Next oPic
    End With
    With Range("F3")
    For Each oPic In Me.Pictures
    If oPic.Name = .Text Then
    oPic.Visible = True
    oPic.Top = .Top
    oPic.Left = .Left
    Exit For
    End If
    Next oPic
    End With
    With Range("F4")
    For Each oPic In Me.Pictures
    If oPic.Name = .Text Then
    oPic.Visible = True
    oPic.Top = .Top
    oPic.Left = .Left
    Exit For
    End If
    Next oPic
    End With
    With Range("F5")
    For Each oPic In Me.Pictures
    If oPic.Name = .Text Then
    oPic.Visible = True
    oPic.Top = .Top
    oPic.Left = .Left
    Exit For
    End If
    Next oPic
    End With
    End Sub


    How can I change this so as not to hide a previous image if the next cell is the same?
    Thankyou and I hope someone can help.
    Last edited by Danoprimo; 03-13-2013 at 04:07 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1