Change picture according to cell content

  • Thread starter Thread starter paulma
  • Start date Start date
P

paulma

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
 
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
 
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
 
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 here:

ftp://ftp.mcgimpsey.com/excel/paulma_demo.xls

Enter "dog", "cat" or "hamster" in A1 and the pictures will change.
 
Back
Top