Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default If Image. . .?


Greetings,


I’m trying to recreate a weather chart via excel, I got excel
populating the information from a URL. I would like to know if it’s
possible to have a picture / image change according to a word.

Example: if the word Sunny is in cell B2 then a Sun Icon would appear
in cell A1, but if it says Cloudy then the Cloudy Icon appears.

Thanking you in advance,


--
Fable


------------------------------------------------------------------------
Fable's Profile: http://www.excelforum.com/member.php...fo&userid=2185
View this thread: http://www.excelforum.com/showthread...hreadid=378464

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 923
Default If Image. . .?

Images placed on a worksheet are part of the SHAPES collection. For example
the two shapes called Picture 1 and Picture 2 have been placed on top of
each other on the same sheet. Either is visible depending on the value of
cell A1.

If Range("A1") = "Sunny" Then
ActiveSheet.Shapes("Picture 1").Visible = True
ActiveSheet.Shapes("Picture 2").Visible = False
Else
ActiveSheet.Shapes("Picture 1").Visible = False
ActiveSheet.Shapes("Picture 2").Visible = True
Endif

--
Cheers
Nigel



"Fable" wrote in
message ...

Greetings,


I'm trying to recreate a weather chart via excel, I got excel
populating the information from a URL. I would like to know if it's
possible to have a picture / image change according to a word.

Example: if the word Sunny is in cell B2 then a Sun Icon would appear
in cell A1, but if it says Cloudy then the Cloudy Icon appears.

Thanking you in advance,


--
Fable


------------------------------------------------------------------------
Fable's Profile:

http://www.excelforum.com/member.php...fo&userid=2185
View this thread: http://www.excelforum.com/showthread...hreadid=378464



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 747
Default If Image. . .?

Put your pictures in cell A1 and have code like this in the worksheet code
module:

Private Sub Worksheet_Change(ByVal Target As Range)
With ActiveSheet
.Shapes("Picture 1").Visible = (Range("B1") = "Sunny")
.Shapes("Picture 2").Visible = (Range("B1") = "Cloudy")
.Shapes("Picture 3").Visible = (Range("B1") = "Raining")
.Shapes("Picture 4").Visible = (Range("B1") = "Snow")
etc....
End With
End Sub

Regards,
Greg


"Fable" wrote:


Greetings,


Im trying to recreate a weather chart via excel, I got excel
populating the information from a URL. I would like to know if its
possible to have a picture / image change according to a word.

Example: if the word Sunny is in cell B2 then a Sun Icon would appear
in cell A1, but if it says Cloudy then the Cloudy Icon appears.

Thanking you in advance,


--
Fable


------------------------------------------------------------------------
Fable's Profile: http://www.excelforum.com/member.php...fo&userid=2185
View this thread: http://www.excelforum.com/showthread...hreadid=378464


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default If Image. . .?


Hello Fable,

Since worksheet cells aren't able to display pictures you will need to
add an Image Object to the worksheet. The Image Object can then be
loaded with the picture. Using the worksheet Change Event, the
appropriate cell or cells can be monitored to determine which picture
will be displayed. You could size the Image Object to match the cell's
size. If you do, make sure the picture size matches as well.

EXAMPLE USING IMAGE1 ON WORKSHEET 1 SIZED TO CELL A1'S BORDERS:


Code:
--------------------
Private Sub Worksheet_Change(ByVal Target As Excel.Range)

Dim Pic

If Target.Address = \"$B$2\" Then
Select Case Target.Value
Case Is = \"sunny\"
Pic = \"C:\My Documents\My Pictures\sunny.jpg\"
Case Is = \"cloudy\"
Pic = \"C:\My Documents\My Pictures\cloudy.jpg\"
Case Else
Pic = \"\"
End Select
Image1.Picture = stdole.LoadPicture(Pic)
End If

End Sub
--------------------


More Case statements can be added to display more weather pictures as
needed. You have to know the pictures path before it can be displayed.


--
Leith Ross


------------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465
View this thread: http://www.excelforum.com/showthread...hreadid=378464

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
Hyperlink to an image in other worksheet, displaying entire image. twilliams Excel Worksheet Functions 0 February 7th 06 10:02 PM
Displaying a Tif image in the Image Control Neil Excel Programming 1 September 21st 04 12:56 AM
copy shape image into image control Luc Benninger Excel Programming 2 July 15th 04 11:14 AM
Export the worksheet background image as an image file - possible? DataFreakFromUtah Excel Programming 2 April 10th 04 04:49 PM
Open image from web in window same size as image? Milos Setek Excel Programming 0 February 5th 04 03:33 AM


All times are GMT +1. The time now is 12:50 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"