Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
Soundman
 
Posts: n/a
Default Worksheet_Change help


Hi all,

I have a series of simple pictures in a spreadsheet. Depending on what
the user inputs into A1, I want A2 to show the corresponding picture.
For example if the type "cat" in A1, then A2 would show a picture of a
cat. The pictues are already in the spreadsheet, and it seems like the
worksheet_change should do what I'm trying to do, but I can't get it to
work. Basically, when they change the cell, I want it to run a macro
that will copy & paste the appropriate cell with the appropriate
picture into A2. If I manually copy & paste the cell it works, but I'm
looking for a way to automatically do that.

I've also tried naming the picture & using an if function. IE: =if
(A1="cat",cat,""). But what that did was paste the words "group312" in
the cell instead of the picture.

Can anyone help?

Thanks,
Bill


--
Soundman
------------------------------------------------------------------------
Soundman's Profile: http://www.excelforum.com/member.php...o&userid=24428
View this thread: http://www.excelforum.com/showthread...hreadid=557357

  #2   Report Post  
Posted to microsoft.public.excel.misc
Bob Phillips
 
Posts: n/a
Default Worksheet_Change help

A suggested different approach.

Copy all the pictures to your target area, and make them non-visible. Then
add this code

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim shp As Shape
On Error GoTo ws_exit
Application.EnableEvents = False
If Target.Address = "$A$1" Then
For Each shp In Me.Shapes
If Left(shp.Name, 4) = "pic_" Then
shp.Visible = False
End If
Next shp
On Error Resume Next
Me.Shapes("pic_" & Target.Value).Visible = True
End If

ws_exit:
Application.EnableEvents = True
On Error GoTo 0
End Sub


This is worksheet event code, which means that it needs to be
placed in the appropriate worksheet code module, not a standard
code module. To do this, right-click on the sheet tab, select
the View Code option from the menu, and paste the code in.

--

HTH

Bob Phillips

(replace xxxx in the email address with gmail if mailing direct)

"Soundman" wrote in
message ...

Hi all,

I have a series of simple pictures in a spreadsheet. Depending on what
the user inputs into A1, I want A2 to show the corresponding picture.
For example if the type "cat" in A1, then A2 would show a picture of a
cat. The pictues are already in the spreadsheet, and it seems like the
worksheet_change should do what I'm trying to do, but I can't get it to
work. Basically, when they change the cell, I want it to run a macro
that will copy & paste the appropriate cell with the appropriate
picture into A2. If I manually copy & paste the cell it works, but I'm
looking for a way to automatically do that.

I've also tried naming the picture & using an if function. IE: =if
(A1="cat",cat,""). But what that did was paste the words "group312" in
the cell instead of the picture.

Can anyone help?

Thanks,
Bill


--
Soundman
------------------------------------------------------------------------
Soundman's Profile:

http://www.excelforum.com/member.php...o&userid=24428
View this thread: http://www.excelforum.com/showthread...hreadid=557357



  #3   Report Post  
Posted to microsoft.public.excel.misc
Bob Phillips
 
Posts: n/a
Default Worksheet_Change help

Oh yes, make sure they are all named pic_xxx such as pic_cat, pic_dog

--

HTH

Bob Phillips

(replace xxxx in the email address with gmail if mailing direct)

"Soundman" wrote in
message ...

Hi all,

I have a series of simple pictures in a spreadsheet. Depending on what
the user inputs into A1, I want A2 to show the corresponding picture.
For example if the type "cat" in A1, then A2 would show a picture of a
cat. The pictues are already in the spreadsheet, and it seems like the
worksheet_change should do what I'm trying to do, but I can't get it to
work. Basically, when they change the cell, I want it to run a macro
that will copy & paste the appropriate cell with the appropriate
picture into A2. If I manually copy & paste the cell it works, but I'm
looking for a way to automatically do that.

I've also tried naming the picture & using an if function. IE: =if
(A1="cat",cat,""). But what that did was paste the words "group312" in
the cell instead of the picture.

Can anyone help?

Thanks,
Bill


--
Soundman
------------------------------------------------------------------------
Soundman's Profile:

http://www.excelforum.com/member.php...o&userid=24428
View this thread: http://www.excelforum.com/showthread...hreadid=557357



  #4   Report Post  
Posted to microsoft.public.excel.misc
Soundman
 
Posts: n/a
Default Worksheet_Change help


Thaks for the input. I'll try that & see how it goes.


--
Soundman
------------------------------------------------------------------------
Soundman's Profile: http://www.excelforum.com/member.php...o&userid=24428
View this thread: http://www.excelforum.com/showthread...hreadid=557357

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



All times are GMT +1. The time now is 08:45 AM.

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"