+ Reply to Thread
Results 1 to 7 of 7

color coding shapes

  1. #1
    Registered User
    Join Date
    03-19-2014
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    48

    color coding shapes

    Hi all,

    Hoping someone can help. I am trying to do some nutritional scoring, but ive created a small sample in the attached workbook.

    I have the code that says if a number is smaller in column L than M then turn it red, if its larger, turn it green. There are some examples where there are no values. but as this is updated regularly these could have values at some point. Is there anyway to make this macro do the same thing it does now, but if there is no value like in rows 8 & 11 then the corresponding shapes will turn gray?

    Thanks
    Attached Files Attached Files

  2. #2
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: color coding shapes

    Something like this???

    Please Login or Register  to view this content.
    Martin

  3. #3
    Registered User
    Join Date
    03-19-2014
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    48

    Re: color coding shapes

    Hi martin,

    I have attached the code with the addition you made to gray out any cells that are 0/blank. but it's not working for me. It was ok when I had it just looking at 1 row (1 piece of code) but it grayed out a random shape.

    Do you have any suggestions as to what I have done wrong?

    Thanks so much for your help!

  4. #4
    Registered User
    Join Date
    03-19-2014
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    48

    Re: color coding shapes

    would have helped it I had attached the file in the 1st place
    Attached Files Attached Files

  5. #5
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: color coding shapes

    Your code is changing the colour of whichever shape is currently selected. Your code is selecting first and then changing the colour - I had not included the selection step so the colour was changed on whatever shape was currently selected.

    Try

    Please Login or Register  to view this content.
    as a more direct way of changing the colour. It avoids selection altogether which makes the code run faster.

  6. #6
    Registered User
    Join Date
    03-19-2014
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    48

    Re: color coding shapes

    Hey Martin,

    Thanks for your response, I certainly see the value of trimming the code down as I have 200+ items in my actual file as opposed to the 10 I included in my file

    I guess your response only pasted 1 line of the code which shows turning one "shape" red. I would appreciate if you could re-paste the full code you had written which show Red, Green, & Gray depending on what is selected.

    Thanks and have a great day! I still find VBA very comlex, but it's gradually making more sense the more i use it, very addictive! the more I learn and understand the power of it, the more i want to incorporate it into files.


    If you have any recommendations on books they would be welcome!

  7. #7
    Registered User
    Join Date
    03-19-2014
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    48

    Re: color coding shapes

    Just wanted to put this back out there. I have played around with varying codes I have found online, but none that I am able to make work to show number larger than, smaller than, or no value. again very appreciative of anyone that can help, and very willing to learn as much as I can from you all!

+ 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. Color Shapes in a Sheet after meeting a Condition
    By hichamh in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-03-2014, 11:26 PM
  2. Coding Macros for a Class- Shapes, area, etc.
    By TylerJamison in forum Excel General
    Replies: 1
    Last Post: 11-09-2012, 05:08 PM
  3. Help with loop to fill color of shapes (US map)
    By harleyberger in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-28-2012, 01:50 PM
  4. Color a shape of a group of shapes
    By lgiannetti in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-13-2011, 09:18 AM
  5. Changing Shapes line color using VBA
    By ABabeNChrist in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 11-23-2010, 10:58 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