Graphics Call With Macro - How to Exclude Some Pix?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a macro in a worksheet that works in conjunction with a VLOOKUP to
display pictures based on the VLOOKUP. The appropriate picture displays at
the P16 cell location. My problem is when I put the macro in, it makes ALL
my graphic objects (PICTURE) disappear except for the one the VLOOKUP calls
for. How can I exclude some of the other graphic objects that are on the
sheet? I tried renaming the objects and it still didn't work i.e.(Picture
100 to Pic 100 and also tried Obj 100). It know someway that it's a graphic.
Here's the code I used:

Private Sub Worksheet_Calculate()
Dim oPic As Picture
Me.Pictures.Visible = False
With Range("P16")
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
 
You have a response in .excel
I have a macro in a worksheet that works in conjunction with a VLOOKUP to
display pictures based on the VLOOKUP. The appropriate picture displays at
the P16 cell location. My problem is when I put the macro in, it makes ALL
my graphic objects (PICTURE) disappear except for the one the VLOOKUP calls
for. How can I exclude some of the other graphic objects that are on the
sheet? I tried renaming the objects and it still didn't work i.e.(Picture
100 to Pic 100 and also tried Obj 100). It know someway that it's a graphic.
Here's the code I used:

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

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

Back
Top