Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 122
Default PLACING PIC IN WORKSHEET USING MACRO

I have built a worksheet with the following macro to insert a picture if a
certain cell is true. My question is that:
I have three more pics to add if other individual cells are true. How do i
code this? The following is the code that David gave to me and it works fine
for that one picture. But two or more pictures for different cells??????
Thanks,
GlennOption Explicit

Private Sub Worksheet_Calculate()
Dim oPic As Picture
Me.Pictures.Visible = False
With Range("I2")
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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default PLACING PIC IN WORKSHEET USING MACRO

Maybe...

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

Set myRng = Me.Range("I2,J3,K5")

Me.Pictures.Visible = False
For Each myCell In myRng.Cells
With myCell
For Each oPic In Me.Pictures
If LCase(oPic.Name) = LCase(.Text) Then
oPic.Visible = True
oPic.Top = .Top
oPic.Left = .Left
End If
Next oPic
End With
Next myCell

End Sub

If you have multiple pictures associated with the same cell, then I'd use a
unique identifier to be able to find that picture. Then use that value in the
cell and in the name of the picture.

Pict_1_text1_A1
Pict_2_text1_A1
Pict_3_text1_A1

for pictures associated with A1 when A1 has text1 in it. Kind of...
if lcase(opic.name) like lcase("*_" & .text & "_" & .address(0,0)) then

But I'm not sure if that's what you mean.

Glenn wrote:

I have built a worksheet with the following macro to insert a picture if a
certain cell is true. My question is that:
I have three more pics to add if other individual cells are true. How do i
code this? The following is the code that David gave to me and it works fine
for that one picture. But two or more pictures for different cells??????
Thanks,
GlennOption Explicit

Private Sub Worksheet_Calculate()
Dim oPic As Picture
Me.Pictures.Visible = False
With Range("I2")
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
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
Placing external data in a worksheet Ken East End Excel Worksheet Functions 1 September 13th 08 08:04 PM
Searching for data and placing in new worksheet Davey T Excel Worksheet Functions 0 August 26th 07 06:12 PM
retaining fonts when placing excel worksheet into pagemaker? parrydise Excel Discussion (Misc queries) 1 June 29th 05 04:19 PM
PLACING PIC IN WORKSHEET USING MACRO Glenn Excel Programming 1 April 27th 05 11:27 PM
Worksheet reference (i.e placing worksheet name in a cell) Roger Roger Excel Worksheet Functions 1 January 20th 05 03:40 PM


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

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"