Closed Thread
Results 1 to 11 of 11

Change Shape Fill colour based on cells values.

  1. #1
    Forum Contributor pipoliveira's Avatar
    Join Date
    08-09-2012
    Location
    Ireland
    MS-Off Ver
    Microsoft Office 365 ProPlus
    Posts
    368

    Change Shape Fill colour based on cells values.

    Hi there everyone,

    I wonder if you can help me here.

    I need to change the Shape Fill color based on cells drop down menu value, this value is "Yes" and "No"

    I have attached a sample file to this thread.

    What I need is:

    - If cells are empty, I want the Shape color as red.
    - If one of the cells value is "No" or one of the cells is empty, I want the Shape color as yellow
    - If all cells value is "Yes", I want the Shape color green.

    I'm sorry, I am very new with VBA and I've no idea about the code for this one.

    You assistance on this matter will be highly appreciated.

    Many thanks in advance and kind regards,
    Filipe
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor
    Join Date
    08-13-2012
    Location
    Gardony, Hungary
    MS-Off Ver
    Excel 2003
    Posts
    558

    Re: Change Shape Fill colour based on cells values.

    Hi,

    try and copy this into sheet1 module.
    Please Login or Register  to view this content.

  3. #3
    Forum Contributor pipoliveira's Avatar
    Join Date
    08-09-2012
    Location
    Ireland
    MS-Off Ver
    Microsoft Office 365 ProPlus
    Posts
    368

    Re: Change Shape Fill colour based on cells values.

    Thanks a million for that RHCPgergo.

    That's the code I was looking for.

    This is only a sample as I need to do something similar but with lots of Shapes.

    Can you please confirm if for each shape I need to put the same code and only change the line where the shape name is as following:

    Please Login or Register  to view this content.
    And just one more thing, where can I find each color number? for example, red is 2; green is 3...

    Many thanks in advance and kind regards,
    Filipe

  4. #4
    Valued Forum Contributor
    Join Date
    08-13-2012
    Location
    Gardony, Hungary
    MS-Off Ver
    Excel 2003
    Posts
    558

    Re: Change Shape Fill colour based on cells values.

    I'm glad it works!

    Here is the adjusted one. Please make sure that each Oval is named properly. (They have to be named like Oval2, Oval3, etc. Each number representing the row of the data it belongs to. Don't use space. "Oval 2" is wrong.) I added a macro that names the Ovals if you run it, but I didn't test it. Read the comments in the code for extra info. (Alt+F11 to open VBA in Excel.)
    Attached Files Attached Files

  5. #5
    Forum Contributor pipoliveira's Avatar
    Join Date
    08-09-2012
    Location
    Ireland
    MS-Off Ver
    Microsoft Office 365 ProPlus
    Posts
    368

    Re: Change Shape Fill colour based on cells values.

    Perfect, thanks for the very useful tip, really appreciated.

    The other thing I need to know is the color numbers. I've seen few ColorIndex in Internet but the numbers you have maintained on my example, does not matches the ones I saw.

    Can I please ask you where can I find a color index for the code you have provided? I need other color for my project, such as Black; Grey, etc.

    Many thanks in advance and kind regards,
    Filipe.

  6. #6
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,528

    Re: Change Shape Fill colour based on cells values.

    If you want to see the difference between ColorIndex and SchemeColor, run the following code
    in a new (empty) workbook. You'll see different Colors for the same numbers between the
    colored Cells and colored Ovals.


    Please Login or Register  to view this content.
    Last edited by jolivanes; 12-16-2012 at 07:18 PM.

  7. #7
    Forum Contributor pipoliveira's Avatar
    Join Date
    08-09-2012
    Location
    Ireland
    MS-Off Ver
    Microsoft Office 365 ProPlus
    Posts
    368

    Re: Change Shape Fill colour based on cells values.

    Thanks a million for all users involved.

    I really appreciate your fast and amazing reply to my query.

    Best regards,
    Filipe

  8. #8
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,528

    Re: Change Shape Fill colour based on cells values.

    I am just wondering if you have tried any of these.
    I have not used them myself but it would be great to know if and how good they work.

    Good luck Filipe

  9. #9
    Forum Contributor pipoliveira's Avatar
    Join Date
    08-09-2012
    Location
    Ireland
    MS-Off Ver
    Microsoft Office 365 ProPlus
    Posts
    368

    Re: Change Shape Fill colour based on cells values.

    Yes Jolivanes,

    They work perfectly and you can see the different colors between ColorIndex and SchemeColor.

    That's really a brilliant code.

    Thanks a million for this.

    BR,
    Filipe

  10. #10
    Registered User
    Join Date
    07-26-2020
    Location
    Ohio
    MS-Off Ver
    2016
    Posts
    4

    Re: Change Shape Fill colour based on cells values.

    Hello, I just joined this sight and am very new to VGA. I am currently in the process of trying to understand the function. I am in request of a code in this same manner. the code I am looking for function would take the value from the cells in the "Z" column and turn the specific oval either blue, red, yellow, or green. I tried to use the 1 "code fix", but I had no luck. I was unable to download the second excel format to look.

    any help or a point in the correct direction would help

    Thank you
    Attached Files Attached Files

  11. #11
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,980

    Re: Change Shape Fill colour based on cells values.

    Administrative Note:

    Welcome to the forum.

    We are happy to help, however whilst you feel your request is similar to this thread, experience has shown that things soon get confusing when answers refer to particular cells/ranges/sheets which are unique to your post and not relevant to the original.

    Please see Forum Rule #4 about hijacking and start a new thread for your query.

    If you are not familiar with how to start a new thread see the FAQ: How to start a new thread
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

Closed 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