Results 1 to 4 of 4

Conditional Formatting/Traffic LX style is not formatting correctly

Threaded View

  1. #1
    Registered User
    Join Date
    06-02-2014
    Posts
    2

    Conditional Formatting/Traffic LX style is not formatting correctly

    Hi All,
    I'm more than new at VBA, literally just started about 2 months ago in a class, and I didn't even know VBA existed before this class. So, I've created a workbook that has a command button, that takes you to a userform. The user chooses a month, picks a date on the calendar, and enters data into several text boxes. I then have code that goes to the appropriate month tab (one for each of the 12 mo), enters the date in the appropriate cell, and enters the data into the appropriate cells. More code that then calculates the percentage of actual data vs. goal data (so cell D4 = C4/B4, in percentage form).

    My question is, I've tried a few different ways to apply the conditional formatting of traffic light style to the percentage column (D4:D14), but it's not coming up correctly. It keeps coming out either mostly red or mostly green lights, even though you can clearly see that some of the cells are within that yellow color range.

    Here's my code below. I cobbled it together from recording a macro and looking at that, plus mashed together with pieces I've found on the internet. I would greatly appreciate anyone pointing out my idiocy and fixing this. I have been stumped on this all weekend and can't seem to figure out why it's not working.

    Thank you!!!
    Dim rRangeToFormat As Range
       Dim ic As IconCriteria
       
       '--modify to the desired range
       Set rRangeToFormat = Range("D4:D14")
       
       With rRangeToFormat
          With .FormatConditions
             .Delete
             .AddIconSetCondition
          End With
          
          With .FormatConditions(1)
             .SetFirstPriority
             .ReverseOrder = False
             .ShowIconOnly = False
             .IconSet = ActiveWorkbook.IconSets(xl3TrafficLights1)
             With .IconCriteria(2)
                .Type = xlConditionValuePercent
                .Value = 0.4
                .Operator = xlGreaterEqual
             End With
             With .IconCriteria(3)
                .Type = xlConditionValuePercent
                .Value = 0.7
                .Operator = xlGreaterEqual
             End With
          End With
       End With
    End Sub
    Last edited by Leith Ross; 06-23-2014 at 11:41 PM. Reason: Added Code Tags

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Conditional Formatting- Traffic Lights - Using Formulas
    By Nikki Fox in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-21-2013, 10:50 AM
  2. Traffic Light Conditional Formatting
    By hzaz in forum Excel General
    Replies: 4
    Last Post: 05-01-2013, 02:10 PM
  3. Need help with traffic light conditional formatting icon set
    By jjospeh in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-21-2012, 03:33 PM
  4. Conditional Formatting - Traffic light dates
    By zx561 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 08-19-2012, 02:51 PM
  5. Traffic Lights - Conditional Formatting
    By Moe2 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-25-2012, 01:42 AM

Tags for this Thread

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