ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Graphics Call With Macro - How to Exclude Some Pix? (https://www.excelbanter.com/excel-programming/320368-graphics-call-macro-how-exclude-some-pix.html)

DocuMike

Graphics Call With Macro - How to Exclude Some Pix?
 
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


Dave Peterson[_5_]

Graphics Call With Macro - How to Exclude Some Pix?
 
You have a response in .excel

DocuMike wrote:

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


--

Dave Peterson


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

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