Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Change picture according to cell content
I am trying to create an excel sheet where the program changes a picture on
the sheet depending on the contents of a particular cell. For example if cell A1 contains "Cat" I want to display a cat somewhere else on the sheet, if it contains "dog" I want to display a picture of a dog. How would I go about doing this??? Would I need to use VBA and if so How?? Thanks in Advance Paul Martin |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Change picture according to cell content
One way:
Paste your pictures onto the sheet, name them "Dog", "Cat", "Hamster", etc, and position and size them as you want. Put this in the worksheet code module. Private Sub Worksheet_Calculate() Dim picSelect As String picSelect = LCase(Range("A1").Text) Application.ScreenUpdating = False With ActiveSheet .Shapes("Dog").Visible = (picSelect = "dog") .Shapes("Cat").Visible = (picSelect = "cat") .Shapes("Hamster").Visible = (picSelect = "hamster") End With Application.ScreenUpdating = True End Sub In article , "paulma" wrote: I am trying to create an excel sheet where the program changes a picture on the sheet depending on the contents of a particular cell. For example if cell A1 contains "Cat" I want to display a cat somewhere else on the sheet, if it contains "dog" I want to display a picture of a dog. How would I go about doing this??? Would I need to use VBA and if so How?? Thanks in Advance Paul Martin |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Change picture according to cell content
Thanks but I can't get it to work.at present. I created the macro but it
doesn't seem to execute. I only want the picture that should be visible to show. The others should be hidden. Thanks for the help so far Paul "J.E. McGimpsey" wrote in message ... One way: Paste your pictures onto the sheet, name them "Dog", "Cat", "Hamster", etc, and position and size them as you want. Put this in the worksheet code module. Private Sub Worksheet_Calculate() Dim picSelect As String picSelect = LCase(Range("A1").Text) Application.ScreenUpdating = False With ActiveSheet .Shapes("Dog").Visible = (picSelect = "dog") .Shapes("Cat").Visible = (picSelect = "cat") .Shapes("Hamster").Visible = (picSelect = "hamster") End With Application.ScreenUpdating = True End Sub In article , "paulma" wrote: I am trying to create an excel sheet where the program changes a picture on the sheet depending on the contents of a particular cell. For example if cell A1 contains "Cat" I want to display a cat somewhere else on the sheet, if it contains "dog" I want to display a picture of a dog. How would I go about doing this??? Would I need to use VBA and if so How?? Thanks in Advance Paul Martin |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Change picture according to cell content
If your "dog", "cat", etc. values aren'te the result of
calculations, but of user entries, then you need to use the Worksheet_Change() event rather than the Worksheet_Calculate event. I've posted a demo file he ftp://ftp.mcgimpsey.com/excel/paulma_demo.xls Enter "dog", "cat" or "hamster" in A1 and the pictures will change. In article , "J.E. McGimpsey" wrote: One way: Paste your pictures onto the sheet, name them "Dog", "Cat", "Hamster", etc, and position and size them as you want. Put this in the worksheet code module. Private Sub Worksheet_Calculate() Dim picSelect As String picSelect = LCase(Range("A1").Text) Application.ScreenUpdating = False With ActiveSheet .Shapes("Dog").Visible = (picSelect = "dog") .Shapes("Cat").Visible = (picSelect = "cat") .Shapes("Hamster").Visible = (picSelect = "hamster") End With Application.ScreenUpdating = True End Sub In article , "paulma" wrote: I am trying to create an excel sheet where the program changes a picture on the sheet depending on the contents of a particular cell. For example if cell A1 contains "Cat" I want to display a cat somewhere else on the sheet, if it contains "dog" I want to display a picture of a dog. How would I go about doing this??? Would I need to use VBA and if so How?? Thanks in Advance Paul Martin |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Change Cell Content | Excel Discussion (Misc queries) | |||
Change format of cell content | Excel Discussion (Misc queries) | |||
change content of a given cell as different cells are indicated | Excel Worksheet Functions | |||
How can I "glue" a picture in a cell and treat it as content? | Excel Discussion (Misc queries) | |||
how do I change the content of one cell based on another? | Excel Discussion (Misc queries) |