Conditional Formatting in VBA with an Expression

naylorpsu

New Member
Joined
Apr 3, 2018
Messages
7
Good morning, everyone.

I have a static cell ($A$6) on worksheet that is the goal for the number of tickets that should worked on during the week.

Starting at cell (C11), I have a range labeled "rg" that is Dynamic and could span many columns depending on how many teams submitted tickets during that week. This shows the number of Tickets by each team submitted.

I would like to apply conditional formatting within VBA that goes through that range and calculates the following:

Condition 1: if greater than 10%, show in red (too many tickets processed)
Condition 2 : if less than -10%, show in yellow (not enough tickets processed)

This is what i have so far (see below), but not sure how to write the formula for the xlExpression (if i did this right to begin with).

Any help would be greatly appreciated. Thank you in advance! Please let me know if you need any clarification.



Sub C_ConditionalFormatting()

Dim rg As Range
Dim maxValue, minValue As Double

Set rg = Range("C11", Range("C11").End(xlToRight).Offset(0, -1))
Set maxValue = 0.1
Set minValue = -0.1

With Dashboard.Range(rg)

' CONDITION FOR GREATER THAN 10% - reference maxValue
.FormatConditions.Add xlExpression, Formula1:="=NEED FORMULA"
.FormatConditions(1).Interior.Color = RGB(255, 0, 0)

' CONDITION FOR LESS THAN -10% - reference minValue
.FormatConditions.Add xlExpression, Formula2:="=NEED FORMULA"
.FormatConditions(2).Interior.Color = RGB(255, 255, 0)

End With

End Sub
 

Forum statistics

Threads
1,081,690
Messages
5,360,614
Members
400,592
Latest member
badgergurl

Some videos you may like

This Week's Hot Topics

  • VBA (Userform)
    Hi All, I just would like to know why my code isn't working. Here is my VBA code: [CODE=vba]Private Sub OKButton_Click() Dim i As Integer...
  • List box that changes fill color
    Hello, I have gone through so many pages trying to figure this out. I have a 2020 calendar that depending on the day needs to have a certain...
  • Remove duplicates and retain one. Cross-linked cases
    Hi all I ran out of google keywords to use and still couldn't find a reference how to achieve the results of a single count. It would be great if...
  • VBA Copy and Paste With Duplicates
    Hello All, I'm in need of some input. My VBA skills are sub-par at best. I've assembled this code from basic research and it works but is...
  • Macro
    is it possible for a macro to run if the active cell value is different to the value above it
  • IF DATE and TIME
    I currently use this to check if date has passed but i also need to set a time on it too. Is it possible? [CODE=vba]=IF(B:B>TODAY(),"Not...
Top