+ Reply to Thread
Results 1 to 4 of 4

VBA to color the object with criteria and condition

  1. #1
    Forum Contributor
    Join Date
    07-16-2012
    Location
    Fort Worth, Texas
    MS-Off Ver
    Excel 2010
    Posts
    378

    VBA to color the object with criteria and condition

    Hello,

    I have a draw object in excel and I wonder if there is an automatic vba that help me color an object red when cell B14 in a range of -10% to -20% or we can do formula if it is necessary. In addition, I want to be able to display value of cell B14 in the center of the object as well. Thanks.

  2. #2
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: VBA to color the object with criteria and condition

    Hi tantcu,

    VBA can do it quite easily, but we would need a few more details (such as a sample workbook) for that.

    Before you go the VBA route, take a look at CONDITIONAL FORMATTING, which will probably do the job better for you:http://office.microsoft.com/en-us/ex...010370614.aspx

    Lewis

  3. #3
    Forum Contributor
    Join Date
    07-16-2012
    Location
    Fort Worth, Texas
    MS-Off Ver
    Excel 2010
    Posts
    378

    Re: VBA to color the object with criteria and condition

    Hi,

    I understand about conditional formatting and in this case I won't need to use it. I attached a sample in this. For example, if the Texas object is in range 10% - 14% I want it to automatically turn to green and if it is lower than 10 % then apply another condition and turn it to yellow. Please let me know if this is possible since I have to this for 50 states.Test vba on object.xlsx

  4. #4
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: VBA to color the object with criteria and condition

    Very interesting and fun project.

    See the attached file (your file modified) which will get you started (written and tested in Excel 2003).
    1. The file will allow you to:
    a. Color each state as you requested.
    b. Insert the percentage in the center of each state.

    2. There are instructions and Macros to:
    a. Add states (and assign names (e.g. 'CA' for California) to each State shape.
    b. Adjust the centering of Percentage Text (e.g. Florida probably needs adjusting).
    c. Various other capabilities which are explained in the file.

    Please let me know if there's anything else you need.

    Lewis
    Attached Files Attached Files

+ 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. Replies: 3
    Last Post: 01-08-2014, 03:56 PM
  2. Replies: 2
    Last Post: 11-06-2012, 06:40 PM
  3. Replies: 12
    Last Post: 09-18-2012, 03:13 PM
  4. Object color based on cell color
    By wagnered in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-13-2012, 11:56 AM
  5. Getting a picture/object to only appear if condition is met?
    By lealea1982 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 10-24-2007, 05:44 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