Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 172
Default VBA code for sizing/showing pictures

I'm using the following code to size and display a specific picture based on
my list box in cell A4. It does a "VLOOKUP" from cell A5 and then displays
the picture that is tied to the selection in the list box. This code is
specific to cell A5 only. I need to duplicate this function to cell C4 and
cell C5. But I want the picture in cell C5 to be driven by the listbox in
cell C4. How do I set this up since my code is cell specific? I want these to
be independent of each other to allow users to be able to choose a picture
for A5 and then another picture for C5. Here is the VBA code that drives the
A4 listbox and then puts the picture in A5:

Private Sub Worksheet_Calculate()

Dim oPic As Picture
Me.Pictures.Visible = False
With Range("A5")
For Each oPic In Me.Pictures
If oPic.Name = .Text Then
oPic.Visible = True
oPic.ShapeRange.LockAspectRatio = msoFalse
oPic.Top = .Top
oPic.Left = .Left
oPic.Height = .Height
oPic.Width = .Width
oPic.Placement = xlMoveAndSize
Exit For
End If
Next oPic
End With
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default VBA code for sizing/showing pictures

Looks like John McGimpsey's lookuppics code.

Only allows for one image at a time to be displayed.

Got 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 Dibben MS Excel MVP

On Wed, 27 Aug 2008 17:51:19 -0700, Secret Squirrel
wrote:

I'm using the following code to size and display a specific picture based on
my list box in cell A4. It does a "VLOOKUP" from cell A5 and then displays
the picture that is tied to the selection in the list box. This code is
specific to cell A5 only. I need to duplicate this function to cell C4 and
cell C5. But I want the picture in cell C5 to be driven by the listbox in
cell C4. How do I set this up since my code is cell specific? I want these to
be independent of each other to allow users to be able to choose a picture
for A5 and then another picture for C5. Here is the VBA code that drives the
A4 listbox and then puts the picture in A5:

Private Sub Worksheet_Calculate()

Dim oPic As Picture
Me.Pictures.Visible = False
With Range("A5")
For Each oPic In Me.Pictures
If oPic.Name = .Text Then
oPic.Visible = True
oPic.ShapeRange.LockAspectRatio = msoFalse
oPic.Top = .Top
oPic.Left = .Left
oPic.Height = .Height
oPic.Width = .Width
oPic.Placement = xlMoveAndSize
Exit For
End If
Next oPic
End With
End Sub


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
formatting code is showing instead of data. Stellir Excel Discussion (Misc queries) 0 November 7th 07 10:55 PM
Why is a cell formatted as a zip code is showing up as a decimal? Renee' Excel Discussion (Misc queries) 4 February 14th 07 12:30 PM
Pictures not showing or printing JonEllwood Excel Discussion (Misc queries) 8 September 18th 06 10:31 AM
how do i change or make this macro??? pictures and code included dispelthemyth Charts and Charting in Excel 0 March 17th 06 01:02 AM
code for showing a sheet has been printed Giselle Excel Worksheet Functions 0 February 8th 06 11:56 PM


All times are GMT +1. The time now is 06:48 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"