#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2013
    Posts
    7
    Rep Power
    0

    Microsoft Excel - Add exception to a macro displaying pictures


    Hello everyone,

    I'd like to ask for your help regarding a project on Excel.

    What it does:

    If Cell value in "C36" or "D36" is Yes, then a picture will be displayed (either Picture 1 or Picture 2).
    If Cell value is No, then the pictures won't be displayed.

    The code I use:

    Code:
    Private Sub Worksheet_Calculate()
    Dim oPic As Picture
    Me.Pictures.Visible = False
    With Range("C36")
    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("D36")
    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

    My problem:

    By default, all pictures on the Excel sheet are invisible.
    My problem is, there are 3 pictures I'd like to display at all time because they are part of the document's decoration.

    Therefore, I'd like to add an exception for the Picture A, Picture B, Picture C so they are not affected by the command "Me.Pictures.Visible = False".



    Please may I ask if someone could help me and advise which code I should use?

    Please let me know if you need more information.
    Thank you very much in advance.
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2013
    Posts
    7
    Rep Power
    0
    Nevermind, I got the answer.

    PHP Code:
    Me.Pictures.Visible False
    Me
    .Pictures("Picture A").Visible True
    Me
    .Pictures("Picture B").Visible True
    Me
    .Pictures("Picture C").Visible True 

IMN logo majestic logo threadwatch logo seochat tools logo