Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Hyperlink to an image in other worksheet, displaying entire image. | Excel Worksheet Functions | |||
Displaying a Tif image in the Image Control | Excel Programming | |||
copy shape image into image control | Excel Programming | |||
Export the worksheet background image as an image file - possible? | Excel Programming | |||
Open image from web in window same size as image? | Excel Programming |