+ Reply to Thread
Results 1 to 11 of 11

need code to change shape fill to a picture when another cell = 1

  1. #1
    Forum Contributor
    Join Date
    04-09-2014
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    250

    need code to change shape fill to a picture when another cell = 1

    I have set up a rollover hyperlink so that when I hover over the cell it changes colour and creates a good effect. To do this I have another cell on the sheet that turns to 1 when the cell in question is hovered over.

    I need a code so that when that cell displays the number 1. the object (which is rectangle 2) changes from white fill. to a picture I have saved on my desktop.

    I cant quite figure out the coding and have been messing about with things like..

    if cell range e.g a1 = 1 then rectangle 2 .userpicture " path " else .solid etc.

    any ideas

  2. #2
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: need code to change shape fill to a picture when another cell = 1

    That's pretty much right - what actual code did you try and what happened?
    Remember what the dormouse said
    Feed your head

  3. #3
    Forum Contributor
    Join Date
    04-09-2014
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    250

    Re: need code to change shape fill to a picture when another cell = 1

    something like:


    Please Login or Register  to view this content.
    Im aware its wrong but it will give you idea what I want to do and allow you to easily edit it.

  4. #4
    Forum Contributor
    Join Date
    04-09-2014
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    250

    Re: need code to change shape fill to a picture when another cell = 1

    i can edit above code to make it change upon a click to change to image I want.. BUT I cant get it to happen automatically without a click when a cell displays "1". and then need it to go back to white when that cell doesn't display 1

  5. #5
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: need code to change shape fill to a picture when another cell = 1

    Why can't you use the rollover code to call that subroutine?

  6. #6
    Forum Contributor
    Join Date
    04-09-2014
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    250

    Re: need code to change shape fill to a picture when another cell = 1

    im not using a code for the rollover. im using formula:


    =iferror(hyperlink(rollover($a2, a$3),"","") for example. links with other cells and defined name cells & conditional formatting

    so I cant just do that.

  7. #7
    Forum Contributor
    Join Date
    04-09-2014
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    250

    Re: need code to change shape fill to a picture when another cell = 1

    can you give me example code? for if a cell displays "1" fill shape with image? if not, go back to white fill

    automatically? without click

  8. #8
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: need code to change shape fill to a picture when another cell = 1

    Your rollover function is code, therefore it can call the routine you just posted.

  9. #9
    Forum Contributor
    Join Date
    04-09-2014
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    250

    Re: need code to change shape fill to a picture when another cell = 1

    .......How? lol

  10. #10
    Forum Contributor
    Join Date
    04-09-2014
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    250

    Re: need code to change shape fill to a picture when another cell = 1

    little help ..............

  11. #11
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: need code to change shape fill to a picture when another cell = 1

    Add this line:
    Please Login or Register  to view this content.
    to the end of your rollover code. If your rollover function is called on a different sheet from the one the shape is on, you'll need to replace ActiveSheet in the rolloverimage code with the relevant sheet.

    Also, 'please' wouldn't go amiss now and then.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] vba import picture change shape to rectangle
    By alexshaw76 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-05-2014, 01:01 PM
  2. [SOLVED] Change Shape Fill Color Based on Cell Value
    By Justair07 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 11-28-2013, 09:35 AM
  3. Change Color of text on a shape to No Fill
    By gkumthekar in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-28-2013, 04:38 PM
  4. Change shape fill color depending on cell value
    By xe-dingo in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-05-2013, 03:46 AM
  5. [SOLVED] Change fill colour of shape with a click
    By schlepel in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-08-2012, 09:34 AM

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