Linked pictures to cell dropdown

A

Andy Roberts

Hi

I am using the following code which allows me to select a person from a
dropdown and their signature (jpg) appears. It all works well but the code
hides all the other pictures on the sheet (i.e. all the other signatures).
This is what I want it to do but I also have a company logo on the sheet
which I don't want to hide. How do I exclude this one picture from the
"hiding" code?

Option Explicit

Private Sub Worksheet_Calculate()
Dim oPic As Picture
Me.Pictures.Visible = False
With Range("K46")
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
 
Joined
Sep 19, 2012
Messages
11
Reaction score
0
You need to include the name of the logo picture in the check for making visible. Something like the below:

Option Explicit

Private Sub Worksheet_Calculate()
Dim oPic As Picture
Me.Pictures.Visible = False
With Range("K46")
For Each oPic In Me.Pictures
If oPic.Name = .Text or oPic.Name = "name_of_logo_file" Then
oPic.Visible = True
oPic.Top = .Top
oPic.Left = .Left
elseif oPic.Name = "name_of_logo_file" then
oPic.Visible = True
end if
Exit For
End If
Next oPic
End With
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top