Declear which picture I want to show and not?!

P

petterss

Hi!
Here is same code I have wrote:

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

Now all the pictures in the document get invisible!
I want to declear which picture that should be visible or not. Ex. I
want to make picture 1-11 visible = False. How?
How do I decler that a specific picture should be visible, "Picture
101.Visible = True"?

Thanks?
 
N

NickHK

From your code, you are hiding all pictures. Then making the one that
matches the text visible and moving it over cell B41.
So if you want more pictures visible, you need to test for in your For/Next
loop and set them to .visible=true

Where is you list of pictures to make visible ?

NickHK
 
P

petterss

Hi!
The picture I want to be visible are placed in different places in the
document. And in a specific cell I want to show a picture from a list
depending of a choice in an other cell and the other pictures in this
list should be hide.
Can I declear a specific picture to visible? I´m a amateur in VB :) and
would be happy with some excempel!

THanks!
 
N

NickHK

That's what you are doing here.
You are making visible the picture whose .Name matches the .Text in B41.

From your description, I don't see why your code does not do what you need;
hide all except the one with that name.

NickHK
 
P

petterss

It does, the problem is that it hiding other pictures to(ex one logo
one picture in the Heading). Pictures that dont have anything to d
with the list!
Thats why I want to declear picture 102,103 and 104 to visible!
Is it possible?
 
K

Ken Johnson

Hi,

If you are wanting Picture 102, Picture 103 and Picture 104 to remain
visible at all times then try...

Private Sub Worksheet_Calculate()
Dim oPic As Picture
For Each oPic In Me.Pictures
Select Case oPic.Name
Case "Picture 102", "Picture 103", "Picture 104"
Case Else
oPic.Visible = False
End Select
Next oPic
With Range("B41")
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

Ken Johnson
 

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