McGimpsey's Disappearing Pictures

G

Guest

Hi,

I've used the code / formula's in the below link to make pictures
appear/disappear depending on a selection made by a dropdown.

http://www.mcgimpsey.com/excel/lookuppics.html

It works great. However, the VB code instructs all pictures on the
spreadsheet to disappear. I have pictures on the spreadsheet other than those
I need to appear/disappear.

For example if I have two pictures (PPic1 & PPic2) how do i get these to
remain visible while still allowing the formula to work.

I know i need to change/add something to the VB code - but I'm not sure
what. I've included the code below. Any help would be great.

Cheers

Phil

Private Sub Worksheet_Calculate()
Dim oPic As Picture

With Range("B5")

For Each oPic In Me.Pictures
If oPic.Name = .Text Then
oPic.Visible = True
oPic.Top = .Top
oPic.Left = .Left
Else
oPic.Visible = False
Exit For
End If
Next oPic
End With
End Sub
 
J

JE McGimpsey

One way:

Private Sub Worksheet_Calculate()
Dim oPic As Picture
With Range("B5")
For Each oPic In Me.Pictures
If oPic.Name = .Text Then
oPic.Visible = True
oPic.Top = .Top
oPic.Left = .Left
Else
oPic.Visible = oPic.Name Like "PPic[12]"
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