+ Reply to Thread
Results 1 to 4 of 4

Worksheet_Change help

  1. #1
    Registered User
    Join Date
    06-18-2005
    Posts
    17

    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

  2. #2
    Bob Phillips
    Guest

    Re: 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" <[email protected]> wrote in
    message news:[email protected]...
    >
    > 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. #3
    Bob Phillips
    Guest

    Re: 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" <[email protected]> wrote in
    message news:[email protected]...
    >
    > 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. #4
    Registered User
    Join Date
    06-18-2005
    Posts
    17
    Thaks for the input. I'll try that & see how it goes.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1