vba newbie need help.

O

Oligo

hi according to the below link method, how can i use the picture again for
another cell range?
can some kind soul tell me how to write the programming. thanks

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


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

Dave Peterson

Maybe...

Option Explicit
Private Sub Worksheet_Calculate()
Dim oPic As Picture
Dim myCell As Range
Dim myRng As Range

Me.Pictures.Visible = False

'what cells contain the names of the pictures that should be visible?
Set myRng = Me.Range("F1,h9")

For Each myCell In myRng.Cells
With myCell
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
Next myCell
End Sub
 
O

Oligo

thanks dave. it works and solve my problem. thanks so much even though im not
sure about the program hehe.
 

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