ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   McGimpsey's Disappearing Pictures (https://www.excelbanter.com/excel-discussion-misc-queries/49601-mcgimpseys-disappearing-pictures.html)

PW11111

McGimpsey's Disappearing Pictures
 
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

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


In article ,
"PW11111" wrote:

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



All times are GMT +1. The time now is 11:07 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com