Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 493
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 493
Default 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
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
Change Cell Content George Excel Discussion (Misc queries) 2 March 16th 09 02:40 PM
Change format of cell content Dias Excel Discussion (Misc queries) 2 January 22nd 09 06:59 AM
change content of a given cell as different cells are indicated sarah Excel Worksheet Functions 1 May 21st 08 02:41 PM
How can I "glue" a picture in a cell and treat it as content? smaruzzi Excel Discussion (Misc queries) 3 October 25th 06 10:14 AM
how do I change the content of one cell based on another? Barry Excel Discussion (Misc queries) 2 September 3rd 06 10:16 AM


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