Vertical lookup of pictures

D

DJDKAL

I am trying to see if there is a way to lookup a picture in one tab and
insert it into another tab all within the same worksheet. I have tried the
embed function, as well as creating a hyperlink to the picture only to find
the VLOOKUP just returns the text of the link. Please help.
 
G

Gord Dibben

Which requires the pictures to be in the same worksheet as the VLOOKUP and the
code.


Gord Dibben MS Excel MVP
 
D

DJDKAL

Thank you for the quick response. That works great if I have a couple of
pictures in the entire workbook. In this instance, I have hundreds (which
sounds like it might be a database feature, according to the website you
posted which is another demon for me to learn). In addition, there will be
multiple cases where I need to show two or more pictures with one lookup.
For example, I type a parcel number of a property into my input tab. The
other lookup formulas return the contact information of the owner, name,
telephone number, address, etc. of that property. I would like to show
multiple pictures of that parcel when I type the number.
 
D

DJDKAL

I have the pictures, the code, and the VLOOKUP formula in the same tab. I
have the lookup table in another tab. I am getting "Run-time error '1004':
Unable to set the Visible property of the Picture class" when I try to run
the code. The code is identical to the code copied from the below web
address, with the exception of the cell where I want the pictures to show.
Please help.
 
K

Ken Johnson

I have the pictures, the code, and the VLOOKUP formula in the same tab. I
have the lookup table in another tab. I am getting "Run-time error '1004':
Unable to set the Visible property of the Picture class" when I try to run
the code. The code is identical to the code copied from the below web
address, with the exception of the cell where I want the pictures to show.
Please help.

Are you using McGimpsey's LookUpPics and do you have a large number of
pictures on the sheet (maybe more than 50)?
If so, I have seen this problem before.
After so many pictures the oPic Picture object creates the problem.
A workaround I have used in the past is to avoid the Picture object
(Dim oPic as Picture) and instead use the Shape object (Dim shpPic as
Shape). Then use the Shape's Type property (for Pictures, Type=13) to
process Pictures and leave all the other shapes alone.

This sample code positions the visible picture in A1 when its name is
returned by a formula (VLookup) in A1...

Private Sub Worksheet_Calculate()
Dim shpPic As Shape
Application.ScreenUpdating = False
For Each shpPic In Me.Shapes
Select Case shpPic.Type
Case 13
Select Case shpPic.Name
Case Range("A1").Text
shpPic.Visible = True
With Range("A1")
shpPic.Top = .Top
shpPic.Left = .Left
End With
Case Else
shpPic.Visible = False
End Select
End Select
Next shpPic
End Sub


Ken Johnson
 
D

DJDKAL

That works GREAT! Next and hopefully last question.... I want to show
pictures at the same time, in cells C23, I23, C41, and I41. I changed the
"A1" from your code to C23 and it worked. What part of the code do I need to
copy and where do I insert it so that the other three cells also show
pictures?
 
K

Ken Johnson

That works GREAT! Next and hopefully last question.... I want to show
pictures at the same time, in cells C23, I23, C41, and I41. I changed the
"A1" from your code to C23 and it worked. What part of the code do I need to
copy and where do I insert it so that the other three cells also show
pictures?

Hi,

To do that requires two separate loops.
The first loop hides all the pictures.
The second loop shows the relevant picture for each of the four
cells...

Private Sub Worksheet_Calculate()
Dim shpPic As Shape
Application.ScreenUpdating = False
For Each shpPic In Me.Shapes
If shpPic.Type = 13 Then
shpPic.Visible = False
End If
Next shpPic
For Each shpPic In Me.Shapes
Select Case shpPic.Name
Case Range("C23").Text
shpPic.Visible = True
With Range("C23")
shpPic.Top = .Top
shpPic.Left = .Left
End With
Case Range("I23").Text
shpPic.Visible = True
With Range("I23")
shpPic.Top = .Top
shpPic.Left = .Left
End With
Case Range("C41").Text
shpPic.Visible = True
With Range("C41")
shpPic.Top = .Top
shpPic.Left = .Left
End With
Case Range("I41").Text
shpPic.Visible = True
With Range("I41")
shpPic.Top = .Top
shpPic.Left = .Left
End With
End Select
Next shpPic
End Sub

Ken Johnson
 
G

Gord Dibben

I guess you missed this post but here it is again.

Go to Debra Dalgeish's site for a sample workbook from Bernie Dietrick for
adding pictures to selections.

Alows for more than one picture to be displayed based upon a value or item
chosen from DV lists

http://www.contextures.on.ca/excelfiles.html#DataVal

DV0049 - ClipArt Selection

Edit the code to suit.


Gord
 
D

DJDKAL

I did receive it the first time, it just took to long for me to understand
it. The code from the mcgimpsey website was easier for me to understand and
work with. I do appreciate the effort you have put forth in helping me out
though! Thank you!
 
G

Gord Dibben

I see Ken has given you some new code to deal with the multiple images.

Thanks for the feedback.


Gord
 
T

tong kimsong

Dear Peo and everyone,

i have download sample from http://www.mcgimpsey.com/excel/lookuppics.html

it's look very good for me, but i got some problum
when i protect this worksheet, the picture do not come out.

can u show me what is the problem when we protect sheet and how to do if i want to protect it? if anyone know how to do it please help.
here is my email: (e-mail address removed)

thanks,

regards
Kimsong.



Peo Sjoblom wrote:

Re: Vertical lookup of pictures
14-Jul-08

Not without code, here is an exampl

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

-

Regards

Peo Sjoblom

Previous Posts In This Thread:

Vertical lookup of pictures
I am trying to see if there is a way to lookup a picture in one tab and
insert it into another tab all within the same worksheet. I have tried the
embed function, as well as creating a hyperlink to the picture only to find
the VLOOKUP just returns the text of the link. Please help.

Re: Vertical lookup of pictures
Not without code, here is an exampl

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

-

Regards

Peo Sjoblom

Which requires the pictures to be in the same worksheet as the VLOOKUP and
Which requires the pictures to be in the same worksheet as the VLOOKUP and th
code

Gord Dibben MS Excel MVP

Thank you for the quick response.
Thank you for the quick response. That works great if I have a couple of
pictures in the entire workbook. In this instance, I have hundreds (which
sounds like it might be a database feature, according to the website you
posted which is another demon for me to learn). In addition, there will be
multiple cases where I need to show two or more pictures with one lookup.
For example, I type a parcel number of a property into my input tab. The
other lookup formulas return the contact information of the owner, name,
telephone number, address, etc. of that property. I would like to show
multiple pictures of that parcel when I type the number

:

Got to Debra Dalgeish's site for a sample workbook from Bernie Dietrick
Got to Debra Dalgeish's site for a sample workbook from Bernie Dietrick fo
adding pictures to selections

Alows for more than one picture to be displayed based upon a value or ite
chosen from DV list

http://www.contextures.on.ca/excelfiles.html#DataVa

DV0049 - ClipArt Selection

Edit the code to suit

Gord Dibben MS Excel MV


I have the pictures, the code, and the VLOOKUP formula in the same tab.
I have the pictures, the code, and the VLOOKUP formula in the same tab. I
have the lookup table in another tab. I am getting "Run-time error '1004':
Unable to set the Visible property of the Picture class" when I try to run
the code. The code is identical to the code copied from the below web
address, with the exception of the cell where I want the pictures to show.
Please help

:

Re: Vertical lookup of pictures

Are you using McGimpsey's LookUpPics and do you have a large number o
pictures on the sheet (maybe more than 50)
If so, I have seen this problem before
After so many pictures the oPic Picture object creates the problem
A workaround I have used in the past is to avoid the Picture objec
(Dim oPic as Picture) and instead use the Shape object (Dim shpPic a
Shape). Then use the Shape's Type property (for Pictures, Type=13) t
process Pictures and leave all the other shapes alone

This sample code positions the visible picture in A1 when its name i
returned by a formula (VLookup) in A1..

Private Sub Worksheet_Calculate()
Dim shpPic As Shape
Application.ScreenUpdating = False
For Each shpPic In Me.Shapes
Select Case shpPic.Type
Case 13
Select Case shpPic.Name
Case Range("A1").Text
shpPic.Visible = True
With Range("A1")
shpPic.Top = .Top
shpPic.Left = .Left
End With
Case Else
shpPic.Visible = False
End Select
End Select
Next shpPic
End Sub


Ken Johnson

That works GREAT!
That works GREAT! Next and hopefully last question.... I want to show
pictures at the same time, in cells C23, I23, C41, and I41. I changed the
"A1" from your code to C23 and it worked. What part of the code do I need to
copy and where do I insert it so that the other three cells also show
pictures?

:

I guess you missed this post but here it is again.
I guess you missed this post but here it is again.

Go to Debra Dalgeish's site for a sample workbook from Bernie Dietrick for
adding pictures to selections.

Alows for more than one picture to be displayed based upon a value or item
chosen from DV lists

http://www.contextures.on.ca/excelfiles.html#DataVal

DV0049 - ClipArt Selection

Edit the code to suit.


Gord

Re: Vertical lookup of pictures
Thank you so much for the help. It works flawlessly!!

:

I did receive it the first time, it just took to long for me to understand it.
I did receive it the first time, it just took to long for me to understand
it. The code from the mcgimpsey website was easier for me to understand and
work with. I do appreciate the effort you have put forth in helping me out
though! Thank you!

:

I see Ken has given you some new code to deal with the multiple images.
I see Ken has given you some new code to deal with the multiple images.

Thanks for the feedback.


Gord

wrote:

Re: Vertical lookup of pictures

Hi,

To do that requires two separate loops.
The first loop hides all the pictures.
The second loop shows the relevant picture for each of the four
cells...

Private Sub Worksheet_Calculate()
Dim shpPic As Shape
Application.ScreenUpdating = False
For Each shpPic In Me.Shapes
If shpPic.Type = 13 Then
shpPic.Visible = False
End If
Next shpPic
For Each shpPic In Me.Shapes
Select Case shpPic.Name
Case Range("C23").Text
shpPic.Visible = True
With Range("C23")
shpPic.Top = .Top
shpPic.Left = .Left
End With
Case Range("I23").Text
shpPic.Visible = True
With Range("I23")
shpPic.Top = .Top
shpPic.Left = .Left
End With
Case Range("C41").Text
shpPic.Visible = True
With Range("C41")
shpPic.Top = .Top
shpPic.Left = .Left
End With
Case Range("I41").Text
shpPic.Visible = True
With Range("I41")
shpPic.Top = .Top
shpPic.Left = .Left
End With
End Select
Next shpPic
End Sub

Ken Johnson


Submitted via EggHeadCafe - Software Developer Portal of Choice
WPF TreeView Control With Filtering of Nodes Based on Their Levels
http://www.eggheadcafe.com/tutorial...a-bf26b9783a9b/wpf-treeview-control-with.aspx
 
G

Gord Dibben

You have to unlock the DV dropdown cell and the VLOOKUP cell which in John's
example book is F1

Then protect the sheet.


Gord Dibben MS Excel MVP
 

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